#include "config.h"
Include dependency graph for ushell_task.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | ABORT_CHAR CTRL_C |
| #define | BKSPACE_CHAR 0x08 |
| #define | CMD_BACKWARD 0x05 |
| #define | CMD_FORWARD 0x04 |
| #define | CMD_GET_ID 0x07 |
| #define | CMD_GET_STATUS0 0x08 |
| #define | CMD_GET_STATUS1 0x09 |
| #define | CMD_HELP 0x01 |
| #define | CMD_NONE 0x00 |
| #define | CMD_RUN 0x02 |
| #define | CMD_SET_SPEED 0x06 |
| #define | CMD_STOP 0x03 |
| #define | CR 0x0D |
| #define | CTRL_C 0x03 |
| #define | CTRL_Q 0x11 |
| #define | LF 0x0A |
| #define | MSG_ER_CMD_NOT_FOUND "Unknown Command" |
| #define | MSG_HELP "\r\ru : run\r\st : stop\r\fw : forward\r\bw : backward\r\ss : set speed\r\gi : get id\" |
| #define | MSG_PROMPT "\r>" |
| #define | MSG_WELCOME "\rATMEL Motor Control Interface" |
| #define | QUIT_APPEND CTRL_Q |
| #define | STR_BACKWARD "bw" |
| #define | STR_FORWARD "fw" |
| #define | STR_GET_ID "gi" |
| #define | STR_GET_STATUS0 "g0" |
| #define | STR_GET_STATUS1 "g1" |
| #define | STR_HELP "help" |
| #define | STR_RUN "ru" |
| #define | STR_SET_SPEED "ss" |
| #define | STR_STOP "st" |
Functions | |
| void | build_cmd (void) |
| get the full command line to be interpreted. | |
| U8 | mystrncmp (U8 *str1, U8 code *str2, U8 i) |
| compares two strings located in flash code area. | |
| void | parse_cmd (void) |
| decodes full command line into command type and arguments | |
| void | print_msg (U8 code *str) |
| Display an ASCII code string. | |
| void | ushell_task (void) |
| Entry point of the explorer task management. | |
| void | ushell_task_init (void) |
| This function initializes the hardware/software ressources required for ushell task. | |
| #define ABORT_CHAR CTRL_C |
| #define BKSPACE_CHAR 0x08 |
| #define CMD_BACKWARD 0x05 |
| #define CMD_FORWARD 0x04 |
| #define CMD_GET_ID 0x07 |
| #define CMD_GET_STATUS0 0x08 |
| #define CMD_GET_STATUS1 0x09 |
| #define CMD_HELP 0x01 |
| #define CMD_NONE 0x00 |
| #define CMD_RUN 0x02 |
| #define CMD_SET_SPEED 0x06 |
| #define CMD_STOP 0x03 |
| #define CR 0x0D |
| #define CTRL_C 0x03 |
Definition at line 43 of file ushell_task.h.
| #define CTRL_Q 0x11 |
Definition at line 42 of file ushell_task.h.
| #define LF 0x0A |
Definition at line 41 of file ushell_task.h.
| #define MSG_ER_CMD_NOT_FOUND "Unknown Command" |
Definition at line 62 of file ushell_task.h.
| #define MSG_HELP "\r\ru : run\r\st : stop\r\fw : forward\r\bw : backward\r\ss : set speed\r\gi : get id\" |
Definition at line 63 of file ushell_task.h.
| #define MSG_PROMPT "\r>" |
Definition at line 60 of file ushell_task.h.
| #define MSG_WELCOME "\rATMEL Motor Control Interface" |
Definition at line 61 of file ushell_task.h.
| #define QUIT_APPEND CTRL_Q |
Definition at line 46 of file ushell_task.h.
| #define STR_BACKWARD "bw" |
Definition at line 53 of file ushell_task.h.
| #define STR_FORWARD "fw" |
Definition at line 52 of file ushell_task.h.
| #define STR_GET_ID "gi" |
Definition at line 55 of file ushell_task.h.
| #define STR_GET_STATUS0 "g0" |
Definition at line 56 of file ushell_task.h.
| #define STR_GET_STATUS1 "g1" |
Definition at line 57 of file ushell_task.h.
| #define STR_HELP "help" |
Definition at line 51 of file ushell_task.h.
| #define STR_RUN "ru" |
Definition at line 49 of file ushell_task.h.
| #define STR_SET_SPEED "ss" |
Definition at line 54 of file ushell_task.h.
| #define STR_STOP "st" |
Definition at line 50 of file ushell_task.h.
| void build_cmd | ( | void | ) |
get the full command line to be interpreted.
| none |
Definition at line 159 of file ushell_task.c.
References ABORT_CHAR, BKSPACE_CHAR, cmd_str, CR, i_str, parse_cmd(), uart_getchar(), and uart_test_hit().
Referenced by ushell_task().
00160 { 00161 U8 c; 00162 00163 if (uart_test_hit()) //Something new of the UART ? 00164 { 00165 c=uart_getchar(); 00166 switch (c) 00167 { 00168 case CR: 00169 cmd_str[i_str]=0; //Add NULL char 00170 parse_cmd(); //Decode the command 00171 i_str=0; 00172 break; 00173 case ABORT_CHAR: //^c abort cmd 00174 i_str=0; 00175 printf("\r#"); 00176 break; 00177 case BKSPACE_CHAR: //backspace 00178 if(i_str>0) 00179 { 00180 putchar(c); 00181 putchar(' '); 00182 putchar(c); 00183 } 00184 if(i_str>=1) 00185 { 00186 i_str--; 00187 } 00188 break; 00189 00190 default: 00191 cmd_str[i_str++]=c; //append to cmd line 00192 break; 00193 } 00194 } 00195 }
Here is the call graph for this function:

Here is the caller graph for this function:

compares two strings located in flash code area.
| *str1 | ||
| *str2 |
Definition at line 283 of file ushell_task.c.
Referenced by parse_cmd().
00284 { 00285 U8 j; 00286 for(j=0;j<=i;j++) 00287 { 00288 #ifndef AVRGCC 00289 if(*str1!=*str2) 00290 #else 00291 if( pgm_read_byte_near((unsigned int)str1) != pgm_read_byte_near((unsigned int)str2)) 00292 #endif 00293 { 00294 return FALSE; 00295 } 00296 str1++;str2++; 00297 } 00298 return TRUE; 00299 }
Here is the caller graph for this function:

| void parse_cmd | ( | void | ) |
decodes full command line into command type and arguments
This function allows to set the cmd_type to the command type decoded with its respective arguments par_str1 and par_str2
| none |
Definition at line 207 of file ushell_task.c.
References cmd, CMD_BACKWARD, CMD_FORWARD, CMD_GET_ID, CMD_GET_STATUS0, CMD_GET_STATUS1, CMD_HELP, CMD_RUN, CMD_SET_SPEED, CMD_STOP, cmd_str, cmd_type, FALSE, i_str, LSB, MSB, msg_er_cmd_not_found, msg_prompt, mystrncmp(), par_str1, par_str2, print_msg(), str_backward, str_forward, str_get_id, str_get_status0, str_get_status1, str_help, str_run, str_set_speed, str_stop, and TRUE.
Referenced by build_cmd().
00208 { 00209 U8 i=0; 00210 U8 j; 00211 00212 //Get command type 00213 for(i=0;cmd_str[i]!=' ' && i<=i_str;i++); 00214 cmd=TRUE; 00215 00216 //Decode command type 00217 00218 if ( mystrncmp(cmd_str,str_run,i-1)) 00219 { cmd_type=CMD_RUN; } 00220 else if ( mystrncmp(cmd_str,str_stop,i-1)) 00221 { cmd_type=CMD_STOP; } 00222 else if ( mystrncmp(cmd_str,str_help,i-1)) 00223 { cmd_type=CMD_HELP; } 00224 else if ( mystrncmp(cmd_str,str_forward,i-1)) 00225 { cmd_type=CMD_FORWARD; } 00226 else if ( mystrncmp(cmd_str,str_backward,i-1)) 00227 { cmd_type=CMD_BACKWARD; } 00228 else if ( mystrncmp(cmd_str,str_set_speed,i-1)) 00229 { cmd_type=CMD_SET_SPEED; } 00230 else if ( mystrncmp(cmd_str,str_get_id,i-1)) 00231 { cmd_type=CMD_GET_ID; } 00232 else if ( mystrncmp(cmd_str,str_get_status0,i-1)) 00233 { cmd_type=CMD_GET_STATUS0; } 00234 else if ( mystrncmp(cmd_str,str_get_status1,i-1)) 00235 { cmd_type=CMD_GET_STATUS1; } 00236 else 00237 { 00238 if(i_str) 00239 { 00240 print_msg(msg_er_cmd_not_found); 00241 } 00242 print_msg(msg_prompt); 00243 cmd=FALSE; 00244 return; 00245 } 00246 00247 //Get first arg (if any) 00248 if(++i<i_str) 00249 { 00250 j=0; 00251 for(;(cmd_str[i]!=' ')&&(i<i_str);i++) 00252 { 00253 LSB(par_str1[j])=cmd_str[i]; 00254 MSB(par_str1[j])=0; 00255 j++; 00256 } 00257 LSB(par_str1[j])=0;MSB(par_str1[j])=0; 00258 } 00259 else { return; } 00260 00261 //Get second arg (if any) 00262 if(++i<i_str) 00263 { 00264 j=0; 00265 for(;(cmd_str[i]!=' ')&&(i<i_str);i++) 00266 { 00267 LSB(par_str2[j])=cmd_str[i]; 00268 MSB(par_str2[j])=0; 00269 j++; 00270 } 00271 LSB(par_str2[j])=0;MSB(par_str2[j])=0; 00272 } 00273 else { return; } 00274 00275 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void print_msg | ( | U8 code * | str | ) |
Display an ASCII code string.
| *str,: | pointer to string located in flash area |
Definition at line 306 of file ushell_task.c.
Referenced by parse_cmd(), ushell_task(), and ushell_task_init().
00307 { 00308 U8 c; 00309 #ifndef AVRGCC 00310 c=*str++; 00311 while(c!=0) 00312 { 00313 putchar(c); 00314 c=*str++; 00315 } 00316 #else // AVRGCC does not support point to PGM space 00317 c=pgm_read_byte_near((unsigned int)str++); 00318 while(c!=0) 00319 { 00320 putchar(c); 00321 c=pgm_read_byte_near((unsigned int)str++); 00322 } 00323 #endif 00324 00325 }
Here is the caller graph for this function:

| void ushell_task | ( | void | ) |
Entry point of the explorer task management.
This function links perform ushell task decoding to access file system functions.
| none |
Definition at line 94 of file ushell_task.c.
References BOARD_ID, build_cmd(), cmd, CMD_BACKWARD, CMD_FORWARD, CMD_GET_ID, CMD_GET_STATUS0, CMD_GET_STATUS1, CMD_HELP, CMD_NONE, CMD_RUN, CMD_SET_SPEED, CMD_STOP, cmd_type, convert_param1(), FALSE, mci_backward(), mci_direction, mci_forward(), mci_get_measured_current(), mci_get_measured_speed(), mci_run(), mci_run_stop, mci_set_speed(), mci_stop(), msg_er_cmd_not_found, msg_help, msg_prompt, param1, print_hex16(), print_msg(), REV_ID, and SOFT_ID.
Referenced by main().
00095 { 00096 U8 status = 0; 00097 00098 if(cmd==FALSE) 00099 { 00100 build_cmd(); 00101 } 00102 else 00103 { 00104 switch (cmd_type) 00105 { 00106 case CMD_HELP: 00107 print_msg(msg_help); 00108 break; 00109 case CMD_RUN: 00110 mci_run(); 00111 break; 00112 case CMD_STOP: 00113 mci_stop(); 00114 break; 00115 case CMD_FORWARD: 00116 mci_forward(); 00117 break; 00118 case CMD_BACKWARD: 00119 mci_backward(); 00120 break; 00121 case CMD_SET_SPEED: 00122 convert_param1(); 00123 mci_set_speed(param1); 00124 break; 00125 case CMD_GET_ID: 00126 print_hex16(BOARD_ID); 00127 putchar(' '); 00128 print_hex16(SOFT_ID); 00129 putchar(' '); 00130 print_hex16(REV_ID); 00131 break; 00132 case CMD_GET_STATUS0: 00133 status = (mci_direction<<3)|(mci_run_stop<<2); 00134 print_hex16(status); 00135 putchar(' '); 00136 print_hex16(mci_get_measured_speed()); 00137 putchar(' '); 00138 print_hex16(mci_get_measured_current()); 00139 break; 00140 case CMD_GET_STATUS1: 00141 print_hex16(0xDEA); 00142 putchar(' '); 00143 print_hex16(0x123); 00144 break; 00145 default: //Unknown command 00146 print_msg(msg_er_cmd_not_found); 00147 } 00148 cmd_type=CMD_NONE; 00149 cmd=FALSE; 00150 print_msg(msg_prompt); 00151 } 00152 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void ushell_task_init | ( | void | ) |
This function initializes the hardware/software ressources required for ushell task.
| none |
Definition at line 73 of file ushell_task.c.
References cmd, CMD_NONE, cmd_type, FALSE, msg_prompt, msg_welcome, print_msg(), and uart_init().
Referenced by main().
00074 { 00075 uart_init(); 00076 print_msg(msg_welcome); 00077 print_msg(msg_prompt); 00078 cmd=FALSE; 00079 cmd_type=CMD_NONE; 00080 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7