Atmel Software Framework

usbsys.c File Reference
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "usbsys.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_task.h"
#include "device_mass_storage_task.h"
#include "host_mass_storage_task.h"
#include "shell.h"

Macros

#define MSG_BUS_POWERED   "Device is bus-powered"CRLF
 
#define MSG_COPY_CFG_TO_LOCAL   "Copying the /CFG directory from the USB key"CRLF
 
#define MSG_COPY_LOGS_TO_KEY   "Copying the log files to the USB key"CRLF
 
#define MSG_COPY_WEB_TO_LOCAL   "Copying the /WEB directory from the USB key"CRLF
 
#define MSG_DEVICE_FULL_SPEED   "Device is full-speed"CRLF
 
#define MSG_DEVICE_LOW_SPEED   "Device is low-speed"CRLF
 
#define MSG_KO   "KO"CRLF
 
#define MSG_MOVE_LOGS_TO_KEY   "Moving the log files to the USB key"CRLF
 
#define MSG_NO_DEVICE   "No supported device connected"CRLF
 
#define MSG_OK   "OK"CRLF
 
#define MSG_REMOTE_WAKEUP_KO   "Device does not support remote wake-up"CRLF
 
#define MSG_REMOTE_WAKEUP_OK   "Device supports remote wake-up"CRLF
 
#define MSG_SELF_POWERED   "Device is self-powered"CRLF
 
#define MSG_USB_SUSPENDED   "USB is suspended!"CRLF
 

Functions

bool b_usbsys_start (void)
 
eExecStatus e_usbsys_cp_cfg_to_local (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 In host mode, copy the /CFG directory content of the USB MS key to the Control Panel /CFG directory. No parameters. Format: cp_cfg_to_local. More...
 
eExecStatus e_usbsys_cp_logs_to_key (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 In host mode, copy the /LOG directory to the USB MS key. No parameters. Format: cp_logs_to_ukey. More...
 
eExecStatus e_usbsys_cp_web_to_local (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 In host mode, copy the /WEB directory content of the USB MS key to the Control Panel /WEB directory. No parameters. Format: cp_web_to_local. More...
 
eExecStatus e_usbsys_lsusb (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 In host mode, display basic low-level information about the connected device. The device should be supported by the host (configured). No parameters. Format: lsusb. More...
 
eExecStatus e_usbsys_mv_logs_to_key (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 In host mode, move the /LOG directory content to the USB MS key. No parameters. Format: mv_logs_to_ukey. More...
 
static eExecStatus prv_e_usbsys_sync_cp_ukey (eModId xModId, signed short FsNavId, signed portCHAR **ppcStringReply, signed portCHAR *pcStringMsgAction, U8 sync_direction, const char *pcdir_name, bool bDeleteSrc)
 Common synchronization function between the Control Panel and a USB key. More...
 
int sprintf (char *out, const char *format,...)
 

#define MSG_BUS_POWERED   "Device is bus-powered"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_COPY_CFG_TO_LOCAL   "Copying the /CFG directory from the USB key"CRLF
#define MSG_COPY_LOGS_TO_KEY   "Copying the log files to the USB key"CRLF

Referenced by e_usbsys_cp_logs_to_key().

#define MSG_COPY_WEB_TO_LOCAL   "Copying the /WEB directory from the USB key"CRLF
#define MSG_DEVICE_FULL_SPEED   "Device is full-speed"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_DEVICE_LOW_SPEED   "Device is low-speed"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_KO   "KO"CRLF
#define MSG_MOVE_LOGS_TO_KEY   "Moving the log files to the USB key"CRLF

Referenced by e_usbsys_mv_logs_to_key().

#define MSG_NO_DEVICE   "No supported device connected"CRLF

Detailed description of the module: TODO

Referenced by e_usbsys_lsusb(), and prv_e_usbsys_sync_cp_ukey().

#define MSG_OK   "OK"CRLF
#define MSG_REMOTE_WAKEUP_KO   "Device does not support remote wake-up"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_REMOTE_WAKEUP_OK   "Device supports remote wake-up"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_SELF_POWERED   "Device is self-powered"CRLF

Referenced by e_usbsys_lsusb().

#define MSG_USB_SUSPENDED   "USB is suspended!"CRLF

Referenced by e_usbsys_lsusb().

bool b_usbsys_start ( void  )

Start the USB modules.

Returns
true upon success, else false.

References device_mass_storage_task_init(), host_mass_storage_task_init(), and usb_task_init().

Referenced by portTASK_FUNCTION().

eExecStatus e_usbsys_cp_cfg_to_local ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

In host mode, copy the /CFG directory content of the USB MS key to the Control Panel /CFG directory. No parameters. Format: cp_cfg_to_local.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string may be performed here; the caller must thus free this string.
Returns
the status of the command execution. If the status is SHELL_EXECSTATUS_KO, the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK and the response string is not NULL, the caller MUST free the response string.

References DEVICE_TO_HOST, MSG_COPY_CFG_TO_LOCAL, and prv_e_usbsys_sync_cp_ukey().

eExecStatus e_usbsys_cp_logs_to_key ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

In host mode, copy the /LOG directory to the USB MS key. No parameters. Format: cp_logs_to_ukey.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string may be performed here; the caller must thus free this string.
Returns
the status of the command execution. If the status is SHELL_EXECSTATUS_KO, the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK and the response string is not NULL, the caller MUST free the response string.

References HOST_TO_DEVICE, MSG_COPY_LOGS_TO_KEY, and prv_e_usbsys_sync_cp_ukey().

eExecStatus e_usbsys_cp_web_to_local ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

In host mode, copy the /WEB directory content of the USB MS key to the Control Panel /WEB directory. No parameters. Format: cp_web_to_local.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string may be performed here; the caller must thus free this string.
Returns
the status of the command execution. If the status is SHELL_EXECSTATUS_KO, the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK and the response string is not NULL, the caller MUST free the response string.

References DEVICE_TO_HOST, MSG_COPY_WEB_TO_LOCAL, and prv_e_usbsys_sync_cp_ukey().

eExecStatus e_usbsys_lsusb ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

In host mode, display basic low-level information about the connected device. The device should be supported by the host (configured). No parameters. Format: lsusb.

In host mode, display basic low-level information about the connected device. No parameters. Format: lsusb.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns
the status of the command execution.

References CRLF, Get_altset_nb, Get_class, Get_ep_nbr, Get_interface_number, Get_maxpower, Get_nb_ep, Get_nb_supported_interface, Get_PID, Get_protocol, Get_subclass, Get_VID, i, Is_device_self_powered, Is_device_supports_remote_wakeup, Is_host_ready, Is_host_suspended, Is_usb_full_speed_mode, j, MSG_BUS_POWERED, MSG_DEVICE_FULL_SPEED, MSG_DEVICE_LOW_SPEED, MSG_NO_DEVICE, MSG_REMOTE_WAKEUP_KO, MSG_REMOTE_WAKEUP_OK, MSG_SELF_POWERED, MSG_USB_SUSPENDED, NULL, pvPortMalloc(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, SHELL_MAX_MSGOUT_LEN, sprintf(), v_shell_Print_String_To_Requester_Stream(), and vPortFree().

eExecStatus e_usbsys_mv_logs_to_key ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

In host mode, move the /LOG directory content to the USB MS key. No parameters. Format: mv_logs_to_ukey.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use.
acInput. The argument counter. Ignored.
avInput. The argument vector. Ignored
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string may be performed here; the caller must thus free this string.
Returns
the status of the command execution. If the status is SHELL_EXECSTATUS_KO, the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK and the response string is not NULL, the caller MUST free the response string.

References HOST_TO_DEVICE, MSG_MOVE_LOGS_TO_KEY, and prv_e_usbsys_sync_cp_ukey().

static eExecStatus prv_e_usbsys_sync_cp_ukey ( eModId  xModId,
signed short  FsNavId,
signed portCHAR **  ppcStringReply,
signed portCHAR *  pcStringMsgAction,
U8  sync_direction,
const char *  pcdir_name,
bool  bDeleteSrc 
)
static

Common synchronization function between the Control Panel and a USB key.

Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use.
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string may be performed here; the caller must thus free this string.
pcStringMsgActionInput. The message to display when performing the action.
sync_directionInput. The direction of the synchonization(DEVICE_TO_HOST or HOST_TO_DEVICE)
pcdir_nameInput. The name of the directory to synchronize.
bDeleteSrcInput. Flag to perform a copy(false) or a move(true).
Returns
the status of the command execution. If the status is SHELL_EXECSTATUS_KO, the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK and the response string is not NULL, the caller MUST free the response string.

References host_mass_storage_task_sync_drives(), Is_host_ready, Is_host_suspended, MSG_KO, MSG_NO_DEVICE, MSG_OK, NULL, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_shell_Print_String_To_Requester_Stream().

Referenced by e_usbsys_cp_cfg_to_local(), e_usbsys_cp_logs_to_key(), e_usbsys_cp_web_to_local(), and e_usbsys_mv_logs_to_key().

int sprintf ( char *  out,
const char *  format,
  ... 
)