#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) |
Referenced by ushell_cmd_append_file(), ushell_cmd_scan(), ushell_more_wait(), and ushell_task_init().
#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 |
Referenced by ushell_cmd_perform_extaccess().
#define USHELL_HISTORY 10 |
Referenced by ushell_cmd_decode(), ushell_history_down(), ushell_history_up(), and ushell_task_init().
#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 |
Referenced by ushell_cmd_ls(), ushell_cmd_scan(), and ushell_cmd_sync().
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.
b_more | enable the '|more' management |
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_copy | ( | void | ) |
This function copies a file to other location.
References COPY_BUSY, COPY_FAIL, FS_NAME_GET, g_s_arg, MAX_FILE_PATH_LENGTH, MSG_ER_PASTE, MSG_ER_UNKNOWN_FILE, MSG_KO, nav_file_copy(), nav_file_name(), nav_file_paste_start(), nav_file_paste_state(), nav_getindex(), nav_gotoindex(), and nav_setcwd().
Referenced by ushell_task().
uint8_t ushell_cmd_decode | ( | void | ) |
decodes full command line into command type and arguments
@return the command type decoded
//! The arguments are storage in g_s_arg global array //!
References CMD_APPEND, CMD_CAT, CMD_CAT_MORE, CMD_CD, CMD_CP, CMD_DF, CMD_FORMAT, CMD_GOTO_ID, CMD_HELP, CMD_LS, CMD_LS_MORE, CMD_LS_USB, CMD_MKDIR, CMD_MOUNT, CMD_MV, CMD_NB_DRIVE, CMD_NONE, CMD_PERFORM, CMD_RM, CMD_SET_ID, CMD_SPACE, CMD_SYNC, CMD_TOUCH, cmd_type, CMD_UP, CMD_USB_RESUME, CMD_USB_SUSPEND, g_s_arg, g_s_cmd, g_s_cmd_his, g_u8_cmd_size, g_u8_history_pos, g_u8_history_pos_search, MSG_ER_CMD_NOT_FOUND, STR_APPEND, STR_CAT, STR_CAT_MORE, STR_CD, STR_CP, STR_DF, STR_DISK, STR_FORMAT, STR_GOTO, STR_HELP, STR_LS, STR_LS_MORE, STR_LS_USB, STR_MARK, STR_MKDIR, STR_MOUNT, STR_MV, STR_PERFORM, STR_RM, STR_SPACE, STR_SYNC, STR_TOUCH, STR_UP, STR_USB_RESUME, STR_USB_SUSPEND, USHELL_HISTORY, and USHELL_MAX_NB_ARG.
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 | ) |
This function displays the free space of each drive present.
References FS_SHIFT_B_TO_SECTOR, g_s_arg, mem_name(), nav_drive_nb(), nav_drive_set(), nav_getindex(), nav_gotoindex(), nav_partition_freespace(), nav_partition_freespace_percent(), nav_partition_mount(), and nav_partition_space().
Referenced by ushell_task().
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 | ) |
void ushell_cmd_ls | ( | bool | b_more | ) |
This function manages the ls command.
b_more | enable the '|more' management when true otherwise no '|more' management |
References FS_FIND_NEXT, FS_NAME_GET, FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32, g_s_arg, MAX_FILE_PATH_LENGTH, mem_name(), nav_dir_name(), nav_drive_get(), nav_file_checkext(), nav_file_isdir(), nav_file_lgt(), nav_file_name(), nav_filelist_reset(), nav_filelist_set(), nav_partition_type(), ushell_more_wait(), USHELL_NB_LINE, and USHELL_SIZE_CMD_LINE.
Referenced by ushell_task().
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 | ) |
This function mount a drive.
References g_s_arg, MSG_ER_DRIVE, MSG_ER_MOUNT, nav_drive_nb(), nav_drive_set(), nav_getindex(), nav_gotoindex(), and nav_partition_mount().
Referenced by ushell_task().
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_perform | ( | void | ) |
Perform transfer between two devices.
References FILE_ALLOC_SIZE, file_close(), FS_NAV_ID_COPYFILE, FS_NAV_ID_USHELL_CMD, g_s_arg, LUN_ID_USB, nav_drive_get(), nav_file_del(), nav_getindex(), nav_gotoindex(), nav_select(), Fs_file_segment::u16_size, ushell_cmd_perform_access(), ushell_cmd_perform_alloc(), ushell_cmd_perform_extaccess(), and ushell_cmd_perform_transfer().
Referenced by ushell_task().
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 | ||
) |
References file_close(), file_open(), file_write(), FOPEN_MODE_W, FS_ERR_FILE_EXIST, fs_g_status, nav_drive_set(), nav_file_create(), nav_file_del(), nav_partition_mount(), and Fs_file_segment::u16_size.
Referenced by ushell_cmd_perform().
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 | ||
) |
References cpu_cy_2_us(), CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, g_u32_ushell_pba_hz, Get_sys_count, ID_STREAM_ERR, stream_mem_to_mem(), stream_state(), Fs_file_segment::u16_size, Fs_file_segment::u32_addr, and Fs_file_segment::u8_lun.
Referenced by ushell_cmd_perform().
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().
bool ushell_cmd_scan | ( | void | ) |
Get the full command line to be interpreted.
References ASCII_BKSPACE, ASCII_CR, ASCII_ESCAPE, ASCII_LF, g_s_cmd_his, g_u8_cmd_size, g_u8_escape_sequence, g_u8_history_pos, putchar, SHL_USART, usart_read_char(), usart_reset_status(), USART_SUCCESS, ushell_clean_cmd_line(), ushell_history_display(), ushell_history_down(), ushell_history_up(), and USHELL_SIZE_CMD_LINE.
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().
bool ushell_cmd_sync | ( | void | ) |
Synchronize a path with an other path.
References COPY_BUSY, COPY_FINISH, FS_ERR_FILE_EXIST, FS_ERR_NO_DIR, FS_FIND_NEXT, fs_g_status, FS_NAME_GET, FS_NAV_ID_COPYFILE, FS_NAV_ID_USHELL_CMD, g_s_arg, nav_dir_cd(), nav_dir_gotoparent(), nav_dir_make(), nav_file_copy(), nav_file_del(), nav_file_isdir(), nav_file_name(), nav_file_paste_start(), nav_file_paste_state(), nav_filelist_reset(), nav_filelist_set(), nav_getindex(), nav_gotoindex(), nav_select(), nav_setcwd(), status, ushell_path_valid_syntac(), and USHELL_SIZE_CMD_LINE.
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.
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.
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().
void ushell_task | ( | void | ) |
Entry point of the explorer task management.
This function performs uShell decoding to access file-system functions.
References CMD_APPEND, CMD_CAT, CMD_CAT_MORE, CMD_CD, CMD_CP, CMD_DF, CMD_FORMAT, CMD_GOTO_ID, CMD_HELP, CMD_LS, CMD_LS_MORE, CMD_LS_USB, CMD_MKDIR, CMD_MOUNT, CMD_MV, CMD_NB_DRIVE, CMD_NONE, CMD_PERFORM, CMD_RM, CMD_SET_ID, CMD_SPACE, CMD_SYNC, CMD_TOUCH, CMD_UP, CMD_USB_RESUME, CMD_USB_SUSPEND, configTSK_USHELL_PERIOD, FS_NAV_ID_USHELL_CMD, g_b_ushell_task_run, Is_usb_id_device, MSG_ER_CMD_NOT_FOUND, MSG_EXIT, MSG_PROMPT, MSG_WELCOME, nav_drive_set(), nav_exit(), nav_getindex(), nav_gotoindex(), nav_reset(), nav_select(), ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_cd(), ushell_cmd_copy(), ushell_cmd_decode(), ushell_cmd_format(), ushell_cmd_free_space(), ushell_cmd_gotoparent(), ushell_cmd_help(), ushell_cmd_ls(), ushell_cmd_mkdir(), ushell_cmd_mount(), ushell_cmd_nb_drive(), ushell_cmd_perform(), ushell_cmd_rename(), ushell_cmd_rm(), ushell_cmd_scan(), ushell_cmd_space(), ushell_cmd_sync(), ushell_cmd_touch(), ushell_cmdusb_ls(), ushell_cmdusb_resume(), ushell_cmdusb_suspend(), vTaskDelayUntil(), and xTaskGetTickCount().
Referenced by main(), and ushell_task_init().
void ushell_task_init | ( | uint32_t | pba_hz | ) |
This function initializes the hardware/software resources required for ushell task.
References usart_options_t::baudrate, configTSK_USHELL_NAME, configTSK_USHELL_PRIORITY, configTSK_USHELL_STACK_SIZE, g_b_ushell_task_run, g_s_cmd_his, g_u32_ushell_pba_hz, gpio_enable_module(), MSG_EXIT, NULL, SHL_USART, SHL_USART_BAUDRATE, SHL_USART_RX_FUNCTION, SHL_USART_RX_PIN, SHL_USART_TX_FUNCTION, SHL_USART_TX_PIN, USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, USART_NORMAL_CHMODE, USHELL_HISTORY, ushell_task(), and xTaskCreate.
Referenced by main().
Referenced by ushell_task(), and ushell_task_init().
|
static |
|
static |
Referenced by ushell_cmd_append_file(), ushell_cmd_cat(), ushell_cmd_cd(), ushell_cmd_copy(), ushell_cmd_decode(), ushell_cmd_format(), ushell_cmd_free_space(), ushell_cmd_ls(), ushell_cmd_mkdir(), ushell_cmd_mount(), ushell_cmd_perform(), ushell_cmd_rename(), ushell_cmd_rm(), ushell_cmd_sync(), and ushell_cmd_touch().
|
static |
Referenced by ushell_cmd_decode().
|
static |
Referenced by ushell_cmd_decode(), ushell_cmd_scan(), ushell_history_display(), ushell_history_up(), and ushell_task_init().
|
static |
|
static |
Referenced by ushell_clean_cmd_line(), ushell_cmd_decode(), ushell_cmd_scan(), and ushell_history_display().
|
static |
Referenced by ushell_cmd_scan().
|
static |
Referenced by ushell_cmd_decode(), ushell_cmd_scan(), ushell_history_display(), ushell_history_down(), and ushell_history_up().
|
static |
Referenced by ushell_cmd_decode(), ushell_history_display(), ushell_history_down(), and ushell_history_up().
|
static |