ushell_task.c File Reference

#include "ushell_task.h"
#include "ascii.h"
#include "uart_lib.h"
#include "mc_interface.h"

Include dependency graph for ushell_task.c:

Go to the source code of this file.

Functions

void build_cmd (void)
void convert_param1 (void)
U16 debug_get_value1 (void)
U16 debug_get_value2 (void)
void parse_cmd (void)
void print_hex16 (U16 value)
void ushell_task (void)
void ushell_task_init (void)

Variables

static U8 cmd
static U8 cmd_str [26]
static U8 cmd_type
static U8 i_str = 0
U8 code msg_er_cmd_not_found [] = MSG_ER_CMD_NOT_FOUND
U8 code msg_help [] = MSG_HELP
U8 code msg_prompt [] = MSG_PROMPT
U8 code msg_welcome [] = MSG_WELCOME
static U16 par_str1 [8]
static U16 par_str2 [8]
static U16 param1
static U16 param2
S16 speed_error
 Regulation loop error calculation.
U8 code str_backward [] = STR_BACKWARD
U8 code str_forward [] = STR_FORWARD
U8 code str_get_id [] = STR_GET_ID
U8 code str_get_status0 [] = STR_GET_STATUS0
U8 code str_get_status1 [] = STR_GET_STATUS1
U8 code str_help [] = STR_HELP
U8 code str_run [] = STR_RUN
U8 code str_set_speed [] = STR_SET_SPEED
U8 code str_stop [] = STR_STOP


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.

Referenced by ushell_task().

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 caller graph for this function:

void convert_param1 ( void   ) 

Referenced by ushell_task().

Here is the caller graph for this function:

U16 debug_get_value1 ( void   ) 

U16 debug_get_value2 ( void   ) 

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.

Referenced by build_cmd().

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 }

Here is the caller graph for this function:

void print_hex16 ( U16  value  ) 

Referenced by ushell_task().

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.

Parameters:
none 
Returns:
none

Definition at line 99 of file ushell_task.c.

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 }

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.

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 }


Variable Documentation

U8 cmd [static]

Definition at line 39 of file ushell_task.c.

Referenced by parse_cmd(), ushell_task(), and ushell_task_init().

U8 cmd_str[26] [static]

Definition at line 45 of file ushell_task.c.

Referenced by build_cmd(), and parse_cmd().

U8 cmd_type [static]

Definition at line 40 of file ushell_task.c.

Referenced by parse_cmd(), ushell_task(), and ushell_task_init().

U8 i_str = 0 [static]

Definition at line 46 of file ushell_task.c.

Referenced by build_cmd(), and parse_cmd().

U8 code msg_er_cmd_not_found[] = MSG_ER_CMD_NOT_FOUND

Definition at line 61 of file ushell_task.c.

Referenced by parse_cmd(), and ushell_task().

U8 code msg_help[] = MSG_HELP

Definition at line 60 of file ushell_task.c.

Referenced by ushell_task().

U8 code msg_prompt[] = MSG_PROMPT

Definition at line 58 of file ushell_task.c.

Referenced by parse_cmd(), ushell_task(), and ushell_task_init().

U8 code msg_welcome[] = MSG_WELCOME

Definition at line 59 of file ushell_task.c.

Referenced by ushell_task_init().

U16 par_str1[8] [static]

Definition at line 41 of file ushell_task.c.

Referenced by parse_cmd().

U16 par_str2[8] [static]

Definition at line 42 of file ushell_task.c.

Referenced by parse_cmd().

U16 param1 [static]

Definition at line 43 of file ushell_task.c.

Referenced by ushell_task().

U16 param2 [static]

Definition at line 44 of file ushell_task.c.

S16 speed_error

Regulation loop error calculation.

Definition at line 22 of file mc_control.c.

U8 code str_backward[] = STR_BACKWARD

Definition at line 52 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_forward[] = STR_FORWARD

Definition at line 51 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_get_id[] = STR_GET_ID

Definition at line 54 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_get_status0[] = STR_GET_STATUS0

Definition at line 55 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_get_status1[] = STR_GET_STATUS1

Definition at line 56 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_help[] = STR_HELP

Definition at line 50 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_run[] = STR_RUN

Definition at line 48 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_set_speed[] = STR_SET_SPEED

Definition at line 53 of file ushell_task.c.

Referenced by parse_cmd().

U8 code str_stop[] = STR_STOP

Definition at line 49 of file ushell_task.c.

Referenced by parse_cmd().


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