ushell_task.h File Reference

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)
void parse_cmd (void)
void ushell_task (void)
void ushell_task_init (void)


Define Documentation

#define ABORT_CHAR   CTRL_C

Definition at line 40 of file ushell_task.h.

Referenced by build_cmd().

#define BKSPACE_CHAR   0x08

Definition at line 39 of file ushell_task.h.

Referenced by build_cmd().

#define CMD_BACKWARD   0x05

Definition at line 27 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_FORWARD   0x04

Definition at line 26 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_GET_ID   0x07

Definition at line 29 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_GET_STATUS0   0x08

Definition at line 30 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_GET_STATUS1   0x09

Definition at line 31 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_HELP   0x01

Definition at line 23 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_NONE   0x00

Definition at line 22 of file ushell_task.h.

Referenced by ushell_task(), and ushell_task_init().

#define CMD_RUN   0x02

Definition at line 24 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_SET_SPEED   0x06

Definition at line 28 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CMD_STOP   0x03

Definition at line 25 of file ushell_task.h.

Referenced by parse_cmd(), and ushell_task().

#define CR   0x0D

Definition at line 35 of file ushell_task.h.

Referenced by build_cmd().

#define CTRL_C   0x03

Definition at line 38 of file ushell_task.h.

#define CTRL_Q   0x11

Definition at line 37 of file ushell_task.h.

#define LF   0x0A

Definition at line 36 of file ushell_task.h.

#define MSG_ER_CMD_NOT_FOUND   "Unknown Command"

Definition at line 57 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 58 of file ushell_task.h.

#define MSG_PROMPT   "\r>"

Definition at line 55 of file ushell_task.h.

#define MSG_WELCOME   "\rATMEL Motor Control Interface"

Definition at line 56 of file ushell_task.h.

#define QUIT_APPEND   CTRL_Q

Definition at line 41 of file ushell_task.h.

#define STR_BACKWARD   "bw"

Definition at line 48 of file ushell_task.h.

#define STR_FORWARD   "fw"

Definition at line 47 of file ushell_task.h.

#define STR_GET_ID   "gi"

Definition at line 50 of file ushell_task.h.

#define STR_GET_STATUS0   "g0"

Definition at line 51 of file ushell_task.h.

#define STR_GET_STATUS1   "g1"

Definition at line 52 of file ushell_task.h.

#define STR_HELP   "help"

Definition at line 46 of file ushell_task.h.

#define STR_RUN   "ru"

Definition at line 44 of file ushell_task.h.

#define STR_SET_SPEED   "ss"

Definition at line 49 of file ushell_task.h.

#define STR_STOP   "st"

Definition at line 45 of file ushell_task.h.


Function Documentation

void build_cmd ( void   ) 

get the full command line to be interpreted.

Parameters:
none 
Returns:
none

Definition at line 164 of file ushell_task.c.

References ABORT_CHAR, BKSPACE_CHAR, cmd_str, CR, i_str, parse_cmd(), uart_getchar(), and uart_test_hit().

00165 {
00166 U8 c;
00167 
00168    if (uart_test_hit())    //Something new of  the UART ?
00169    {
00170       c=uart_getchar();
00171       switch (c)
00172       {
00173          case CR:
00174             cmd_str[i_str]=0;  //Add NULL char
00175             parse_cmd();    //Decode the command
00176             i_str=0;
00177             break;
00178          case ABORT_CHAR:    //^c abort cmd
00179             i_str=0;
00180             printf("\r#");
00181             break;
00182          case BKSPACE_CHAR:   //backspace
00183             if(i_str>0)
00184             {
00185                putchar(c);
00186                putchar(' ');
00187                putchar(c);
00188             }
00189             if(i_str>=1)
00190             {
00191                i_str--;
00192             }
00193             break;
00194 
00195          default:
00196             cmd_str[i_str++]=c;  //append to cmd line
00197             break;
00198       }
00199    }
00200 }

Here is the call 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

Parameters:
none 
Returns:
none

Definition at line 212 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, par_str1, par_str2, str_backward, str_forward, str_get_id, str_get_status0, str_get_status1, str_help, str_run, str_set_speed, str_stop, and TRUE.

00213 {
00214    U8 i=0;
00215    U8 j;
00216 
00217    //Get command type
00218    for(i=0;cmd_str[i]!=' ' && i<=i_str;i++);
00219    cmd=TRUE;
00220 
00221    //Decode command type
00222 
00223    if ( mystrncmp(cmd_str,str_run,i-1))
00224    {  cmd_type=CMD_RUN; }
00225    else if ( mystrncmp(cmd_str,str_stop,i-1))
00226    {  cmd_type=CMD_STOP; }
00227    else if ( mystrncmp(cmd_str,str_help,i-1))
00228    {  cmd_type=CMD_HELP; }
00229    else if ( mystrncmp(cmd_str,str_forward,i-1))
00230    {  cmd_type=CMD_FORWARD; }
00231    else if ( mystrncmp(cmd_str,str_backward,i-1))
00232    {  cmd_type=CMD_BACKWARD; }
00233    else if ( mystrncmp(cmd_str,str_set_speed,i-1))
00234    {  cmd_type=CMD_SET_SPEED; }
00235    else if ( mystrncmp(cmd_str,str_get_id,i-1))
00236    {  cmd_type=CMD_GET_ID; }
00237    else if ( mystrncmp(cmd_str,str_get_status0,i-1))
00238    {  cmd_type=CMD_GET_STATUS0; }
00239    else if ( mystrncmp(cmd_str,str_get_status1,i-1))
00240    {  cmd_type=CMD_GET_STATUS1; }
00241    else
00242    {
00243       if(i_str)
00244       {
00245         print_msg(msg_er_cmd_not_found);
00246       }
00247       print_msg(msg_prompt);
00248       cmd=FALSE;
00249       return;
00250    }
00251 
00252   //Get first arg (if any)
00253    if(++i<i_str)
00254    {
00255       j=0;
00256       for(;(cmd_str[i]!=' ')&&(i<i_str);i++)
00257       {
00258          LSB(par_str1[j])=cmd_str[i];
00259          MSB(par_str1[j])=0;
00260          j++;
00261       }
00262       LSB(par_str1[j])=0;MSB(par_str1[j])=0;
00263    }
00264    else   {  return; }
00265 
00266    //Get second arg (if any)
00267    if(++i<i_str)
00268    {
00269       j=0;
00270       for(;(cmd_str[i]!=' ')&&(i<i_str);i++)
00271       {
00272          LSB(par_str2[j])=cmd_str[i];
00273          MSB(par_str2[j])=0;
00274          j++;
00275       }
00276       LSB(par_str2[j])=0;MSB(par_str2[j])=0;
00277    }
00278    else   { return; }
00279 
00280 }

void ushell_task ( void   ) 

Entry point of the explorer task management This function links perform ushell task decoding to access file system functions.

Parameters:
none 
Returns:
none

Definition at line 99 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(), REV_ID, and SOFT_ID.

00100 {
00101    U8 status = 0;
00102 
00103    if(cmd==FALSE)
00104    {
00105       build_cmd();
00106    }
00107    else
00108    {
00109       switch (cmd_type)
00110       {
00111          case CMD_HELP:
00112             print_msg(msg_help);
00113             break;
00114          case CMD_RUN:
00115             mci_run();
00116             break;
00117          case CMD_STOP:
00118             mci_stop();
00119             break;
00120          case CMD_FORWARD:
00121             mci_forward();
00122             break;
00123          case CMD_BACKWARD:
00124             mci_backward();
00125             break;
00126          case CMD_SET_SPEED:
00127             convert_param1();
00128             mci_set_speed(param1);
00129             break;
00130          case CMD_GET_ID:
00131             print_hex16(BOARD_ID);
00132             putchar(' ');
00133             print_hex16(SOFT_ID);
00134             putchar(' ');
00135             print_hex16(REV_ID);
00136             break;
00137          case CMD_GET_STATUS0:
00138             status = (mci_direction<<3)|(mci_run_stop<<2);
00139             print_hex16(status);
00140             putchar(' ');
00141             print_hex16(mci_get_measured_speed());
00142             putchar(' ');
00143             print_hex16(mci_get_measured_current());
00144             break;
00145          case CMD_GET_STATUS1:
00146             print_hex16(0xDEA);
00147             putchar(' ');
00148             print_hex16(0x123);
00149             break;
00150          default:    //Unknown command
00151             print_msg(msg_er_cmd_not_found);
00152       }
00153       cmd_type=CMD_NONE;
00154       cmd=FALSE;
00155       print_msg(msg_prompt);
00156    }
00157 }

Here is the call graph for this function:

void ushell_task_init ( void   ) 

This function initializes the hardware/software ressources required for ushell task.

Parameters:
none 
Returns:
none
/

Definition at line 73 of file ushell_task.c.

References cmd, CMD_NONE, cmd_type, FALSE, msg_prompt, msg_welcome, uart_getchar(), uart_init(), and uart_putchar.

00074 {
00075    uart_init();
00076 #ifdef __GNUC__
00077    fdevopen((int (*)(char, FILE*))(uart_putchar),(int (*)(FILE*))uart_getchar); //for printf redirection
00078 #endif
00079    print_msg(msg_welcome);
00080    print_msg(msg_prompt);
00081    cmd=FALSE;
00082    cmd_type=CMD_NONE;
00083    
00084 
00085 }

Here is the call graph for this function:


Generated on Tue Sep 16 18:11:28 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3