Atmel Software Framework

ushell_task.c File Reference
#include "nlao_usart.h"
#include <stdio.h>
#include <string.h>
#include "compiler.h"
#include "board.h"
#include "gpio.h"
#include "usart.h"
#include "ctrl_access.h"
#include "fat.h"
#include "file.h"
#include "navigation.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "cycle_counter.h"
#include "usb_host_enum.h"
#include "usb_host_task.h"
#include "host_mass_storage_task.h"
#include "ushell_task.h"

Macros

#define FILE_ALLOC_SIZE   ((1024*1024L)/512L)
 
#define SIZE_OF_EXT_BUFFER   8
 
#define USHELL_HISTORY   10
 
#define USHELL_MAX_NB_ARG   2
 
#define USHELL_NB_COL   80
 
#define USHELL_NB_LINE   20
 
#define USHELL_SIZE_CMD_LINE   70
 
Shell USART Configuration
#define SHL_USART   (&AVR32_USART0)
 
#define SHL_USART_RX_PIN   AVR32_USART0_RXD_0_0_PIN
 
#define SHL_USART_RX_FUNCTION   AVR32_USART0_RXD_0_0_FUNCTION
 
#define SHL_USART_TX_PIN   AVR32_USART0_TXD_0_0_PIN
 
#define SHL_USART_TX_FUNCTION   AVR32_USART0_TXD_0_0_FUNCTION
 
#define SHL_USART_BAUDRATE   57600
 

Functions

void ushell_clean_cmd_line (void)
 Cleans the command line on the display. More...
 
void ushell_cmd_append_file (void)
 Minimalist file editor to append char to a file. More...
 
void ushell_cmd_cat (bool b_more)
 Manage cat command. More...
 
void ushell_cmd_cd (void)
 This function enter in a directory. More...
 
void ushell_cmd_copy (void)
 This function copies a file to other location. More...
 
uint8_t ushell_cmd_decode (void)
 decodes full command line into command type and arguments More...
 
void ushell_cmd_format (void)
 This function formats a drive. More...
 
void ushell_cmd_free_space (void)
 This function displays the free space of each drive present. More...
 
void ushell_cmd_gotoparent (void)
 This function go back to parent directory. More...
 
void ushell_cmd_help (void)
 This function display the help. More...
 
void ushell_cmd_ls (bool b_more)
 This function manages the ls command. More...
 
void ushell_cmd_mkdir (void)
 This function create a directory. More...
 
void ushell_cmd_mount (void)
 This function mount a drive. More...
 
void ushell_cmd_nb_drive (void)
 This function display all drives present. More...
 
void ushell_cmd_perform (void)
 Perform transfer between two devices. More...
 
void ushell_cmd_perform_access (bool b_sens_write, Fs_file_segment seg)
 
Fs_file_segment ushell_cmd_perform_alloc (uint8_t lun, uint16_t size_alloc)
 
void ushell_cmd_perform_extaccess (bool b_sens_write, Fs_file_segment seg)
 
void ushell_cmd_perform_transfer (Fs_file_segment seg_src, Fs_file_segment seg_dest)
 
void ushell_cmd_rename (void)
 This function renames a file or a directory. More...
 
void ushell_cmd_rm (void)
 This function delete a file or directory. More...
 
bool ushell_cmd_scan (void)
 Get the full command line to be interpreted. More...
 
void ushell_cmd_space (void)
 This function displays the disk space of current drive. More...
 
bool ushell_cmd_sync (void)
 Synchronize a path with an other path. More...
 
void ushell_cmd_touch (void)
 This function create a file. More...
 
void ushell_cmdusb_ls (void)
 In host mode, display basic low level information about the device connected. More...
 
void ushell_cmdusb_resume (void)
 In host mode, resume host from suspend mode. More...
 
void ushell_cmdusb_suspend (void)
 In host mode, set host in suspend mode. More...
 
void ushell_history_display (void)
 Displays the current history. More...
 
void ushell_history_down (void)
 Selects the next command in history list. More...
 
void ushell_history_up (void)
 Selects the previous command in history list. More...
 
bool ushell_more_wait (void)
 This function wait a key press. More...
 
void ushell_path_valid_syntac (char *path)
 Appends the '\' char at the end of path. More...
 
void ushell_task (void)
 Entry point of the explorer task management. More...
 
void ushell_task_init (uint32_t pba_hz)
 This function initializes the hardware/software resources required for ushell task. More...
 

Variables

static bool g_b_ushell_task_run = false
 
static Fs_index g_mark_index
 
static char g_s_arg [USHELL_MAX_NB_ARG][USHELL_SIZE_CMD_LINE]
 
static char g_s_cmd [USHELL_SIZE_CMD_LINE]
 
static char g_s_cmd_his [USHELL_HISTORY][USHELL_SIZE_CMD_LINE]
 
static uint32_t g_u32_ushell_pba_hz
 
static uint8_t g_u8_cmd_size =0
 
static uint8_t g_u8_escape_sequence =0
 
static uint8_t g_u8_history_pos =0
 
static uint8_t g_u8_history_pos_search =0
 
static uint8_t u8_ext_buffer [512 *SIZE_OF_EXT_BUFFER]
 

#define FILE_ALLOC_SIZE   ((1024*1024L)/512L)

Referenced by ushell_cmd_perform().

#define SHL_USART   (&AVR32_USART0)
#define SHL_USART_BAUDRATE   57600

Referenced by ushell_task_init().

#define SHL_USART_RX_FUNCTION   AVR32_USART0_RXD_0_0_FUNCTION

Referenced by ushell_task_init().

#define SHL_USART_RX_PIN   AVR32_USART0_RXD_0_0_PIN

Referenced by ushell_task_init().

#define SHL_USART_TX_FUNCTION   AVR32_USART0_TXD_0_0_FUNCTION

Referenced by ushell_task_init().

#define SHL_USART_TX_PIN   AVR32_USART0_TXD_0_0_PIN

Referenced by ushell_task_init().

#define SIZE_OF_EXT_BUFFER   8
#define USHELL_HISTORY   10
#define USHELL_MAX_NB_ARG   2

Referenced by ushell_cmd_decode().

#define USHELL_NB_COL   80
#define USHELL_NB_LINE   20

Referenced by ushell_cmd_cat(), and ushell_cmd_ls().

#define USHELL_SIZE_CMD_LINE   70

void ushell_clean_cmd_line ( void  )

Cleans the command line on the display.

References ASCII_BKSPACE, g_u8_cmd_size, and putchar.

Referenced by ushell_cmd_scan().

void ushell_cmd_append_file ( void  )

Minimalist file editor to append char to a file.

//! hit ^q to exit and save file
//! 

References ASCII_CR, ASCII_CTRL_Q, ASCII_LF, file_close(), file_open(), file_putc(), FOPEN_MODE_APPEND, g_s_arg, MSG_APPEND_WELCOME, MSG_ER_UNKNOWN_FILE, MSG_KO, nav_setcwd(), putchar, SHL_USART, usart_read_char(), usart_reset_status(), and USART_SUCCESS.

Referenced by ushell_task().

void ushell_cmd_cat ( bool  b_more)

Manage cat command.

Parameters
b_moreenable the '|more' management
Todo:
more management not fully functional with file without CR

References ASCII_CR, ASCII_LF, file_close(), file_eof(), file_getc(), file_open(), FOPEN_MODE_R, g_s_arg, MSG_ER_UNKNOWN_FILE, nav_setcwd(), putchar, ushell_more_wait(), and USHELL_NB_LINE.

Referenced by ushell_task().

void ushell_cmd_cd ( void  )

This function enter in a directory.

References g_s_arg, MSG_ER_UNKNOWN_FILE, nav_setcwd(), and ushell_path_valid_syntac().

Referenced by ushell_task().

void ushell_cmd_format ( void  )

This function formats a drive.

References FS_FORMAT_DEFAULT, g_s_arg, MSG_ER_FORMAT, nav_drive_format(), and nav_drive_set().

Referenced by ushell_task().

void ushell_cmd_free_space ( void  )
void ushell_cmd_gotoparent ( void  )

This function go back to parent directory.

References nav_dir_gotoparent().

Referenced by ushell_task().

void ushell_cmd_help ( void  )

This function display the help.

References MSG_HELP.

Referenced by ushell_task().

void ushell_cmd_ls ( bool  b_more)
void ushell_cmd_mkdir ( void  )

This function create a directory.

References g_s_arg, MSG_KO, and nav_dir_make().

Referenced by ushell_task().

void ushell_cmd_mount ( void  )
void ushell_cmd_nb_drive ( void  )

This function display all drives present.

References mem_name(), and nav_drive_nb().

Referenced by ushell_task().

void ushell_cmd_rename ( void  )

This function renames a file or a directory.

References g_s_arg, MSG_ER_UNKNOWN_FILE, MSG_KO, nav_file_rename(), and nav_setcwd().

Referenced by ushell_task().

void ushell_cmd_rm ( void  )

This function delete a file or directory.

References g_s_arg, MSG_KO, nav_file_del(), nav_getindex(), nav_gotoindex(), and nav_setcwd().

Referenced by ushell_task().

void ushell_cmd_space ( void  )

This function displays the disk space of current drive.

References mem_name(), nav_drive_get(), nav_partition_space(), and putchar.

Referenced by ushell_task().

void ushell_cmd_touch ( void  )

This function create a file.

References g_s_arg, and nav_file_create().

Referenced by ushell_task().

void ushell_cmdusb_ls ( void  )

In host mode, display basic low level information about the device connected.

Note
The device should be supported by the host (configured)

Referenced by ushell_task().

void ushell_cmdusb_resume ( void  )

In host mode, resume host from suspend mode.

References Host_request_resume, Is_host_suspended, and MSG_NO_DEVICE.

Referenced by ushell_task().

void ushell_cmdusb_suspend ( void  )

In host mode, set host in suspend mode.

References Host_request_suspend, Is_host_ready, and MSG_NO_DEVICE.

Referenced by ushell_task().

void ushell_history_display ( void  )

Displays the current history.

References g_s_cmd_his, g_u8_cmd_size, g_u8_history_pos, g_u8_history_pos_search, and putchar.

Referenced by ushell_cmd_scan().

void ushell_history_down ( void  )

Selects the next command in history list.

References g_u8_history_pos, g_u8_history_pos_search, and USHELL_HISTORY.

Referenced by ushell_cmd_scan(), and ushell_history_up().

void ushell_history_up ( void  )

Selects the previous command in history list.

References g_s_cmd_his, g_u8_history_pos, g_u8_history_pos_search, USHELL_HISTORY, and ushell_history_down().

Referenced by ushell_cmd_scan().

bool ushell_more_wait ( void  )

This function wait a key press.

Returns
true, if the action must be continue

References SHL_USART, usart_read_char(), usart_reset_status(), and USART_SUCCESS.

Referenced by ushell_cmd_cat(), and ushell_cmd_ls().

void ushell_path_valid_syntac ( char *  path)

Appends the '\' char at the end of path.

References MAX_FILE_PATH_LENGTH.

Referenced by ushell_cmd_cd(), and ushell_cmd_sync().

bool g_b_ushell_task_run = false
static

Referenced by ushell_task(), and ushell_task_init().

Fs_index g_mark_index
static
char g_s_cmd[USHELL_SIZE_CMD_LINE]
static

Referenced by ushell_cmd_decode().

uint8_t g_u8_cmd_size =0
static
uint8_t g_u8_escape_sequence =0
static

Referenced by ushell_cmd_scan().

uint8_t g_u8_history_pos_search =0
static
uint8_t u8_ext_buffer[512 *SIZE_OF_EXT_BUFFER]
static