Atmel Software Framework

services/usb/_asf_v1/class/mass_storage/examples/device_mass_storage_task.c File Reference
#include "conf_usb.h"
#include "board.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "ctrl_access.h"
#include "scsi_decoder.h"
#include "device_mass_storage_task.h"


void device_mass_storage_task (void)
 Entry point of the device mass-storage task management. More...
void device_mass_storage_task_init (void)
 This function initializes the hardware/software resources required for device mass-storage task. More...
static void usb_mass_storage_cbw (void)
 USB Command Block Wrapper (CBW) management. More...
static void usb_mass_storage_csw (void)
 USB Command Status Wrapper (CSW) management. More...
void usb_sof_action (void)
 usb_sof_action More...


static uint32_t dCBWTag
uint8_t ms_endpoint
volatile bool ms_multiple_drive
static uint16_t sof_cnt
uint8_t usb_LUN

void device_mass_storage_task ( void  )

Entry point of the device mass-storage task management.

This function links the device mass-storage SCSI commands to the USB bus.

References configTSK_USB_DMS_PERIOD, EP_MS_OUT, Is_device_enumerated, Is_usb_out_received, sof_cnt, usb_mass_storage_cbw(), usb_mass_storage_csw(), vTaskDelayUntil(), and xTaskGetTickCount().

Referenced by device_mass_storage_task_init(), and main().

void device_mass_storage_task_init ( void  )

This function initializes the hardware/software resources required for device mass-storage task.

Referenced by b_usbsys_start(), and main().

static void usb_mass_storage_cbw ( void  )

USB Command Block Wrapper (CBW) management.

This function decodes the CBW command and stores the SCSI command.

Check if dCBWSignature is correct

Store CBW Tag to be repeated in CSW

if (bmCBWFlags.bit7 == 1) {direction = IN;}

Dummy CBWCBLength read

Store scsi_command

References dCBWTag, EP_MS_IN, EP_MS_OUT, g_scsi_command, g_scsi_data_remaining, get_cur_lun(), ms_endpoint, ms_multiple_drive, NULL, scsi_decode_command(), Usb_ack_out_received_free, Usb_enable_stall_handshake, usb_format_usb_to_mcu_data, usb_LUN, Usb_read_endpoint_data, usb_read_ep_rxpacket(), and Usb_reset_endpoint_fifo_access.

Referenced by device_mass_storage_task().

static void usb_mass_storage_csw ( void  )

USB Command Status Wrapper (CSW) management.

This function sends the status in relation with the last CBW.

Write CSW Signature

Write stored CBW Tag

Write data residual value

Write command status

References dCBWTag, EP_MS_IN, EP_MS_OUT, g_scsi_data_remaining, g_scsi_status, Is_usb_endpoint_stall_requested, Is_usb_in_ready, Is_usb_out_received, Is_usb_setup_received, Usb_ack_in_ready_send, Usb_ack_out_received_free, usb_format_mcu_to_usb_data, Usb_nb_busy_bank, usb_process_request(), Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.

Referenced by device_mass_storage_task().

uint32_t dCBWTag
uint8_t ms_endpoint

Referenced by usb_mass_storage_cbw().

volatile bool ms_multiple_drive
uint16_t sof_cnt
uint8_t usb_LUN

Referenced by usb_mass_storage_cbw().