#include "conf_access.h"
#include "usb_drv.h"
#include "host_mem.h"
#include "scsi_decoder.h"
#include "usb_host_task.h"
#include "host_mass_storage_task.h"
Functions | |
uint8_t | host_get_lun (void) |
This function returns the number of LUNs of the connected mass-storage device. More... | |
Ctrl_status | host_ms_inquiry (void) |
This function sends an SCSI INQUIRY command (0x12) to the device. More... | |
uint8_t | host_ms_request_sense (void) |
This function sends an SCSI REQUEST SENSE command (0x03) to the device. More... | |
static void | host_ms_stall_management (uint8_t pipe) |
This function manages pipe STALLs. More... | |
Ctrl_status | host_read_10_extram (uint32_t addr, void *ram, uint8_t nb_sector) |
This function transfers 1 data sector from memory to RAM sector = 512 bytes. More... | |
Ctrl_status | host_read_10_ram (uint32_t addr, void *ram) |
This function transfers 1 data sector from memory to RAM sector = 512 bytes. More... | |
static Ctrl_status | host_read_10_ram_stop (void) |
This function terminates the transfer of a physical sector from memory to RAM. More... | |
Ctrl_status | host_read_capacity (uint8_t lun, uint32_t *u32_nb_sector) |
This function returns the address of the last valid sector in the lun. More... | |
uint8_t | host_read_sector_size (uint8_t lun) |
This function returns the physical sector size of the lun. More... | |
bool | host_removal (void) |
This function informs about the memory type. More... | |
Ctrl_status | host_test_unit_ready (uint8_t lun) |
This function tests memory state, and starts memory initialization. More... | |
bool | host_wr_protect (uint8_t lun) |
This function returns the write-protected mode Only used by memory removal with a HARDWARE-SPECIFIC write-protected detection. More... | |
Ctrl_status | host_write_10_extram (uint32_t addr, const void *ram, uint8_t nb_sector) |
This function transfers 1 data sector from RAM to memory sector = 512 bytes. More... | |
Ctrl_status | host_write_10_ram (uint32_t addr, const void *ram) |
This function transfers 1 data sector from RAM to memory sector = 512 bytes. More... | |
Variables | |
static uint8_t | buf_cmd [31] |
uint8_t | g_b_read_run = false |
uint8_t | g_pipe_ms_in |
uint8_t | g_pipe_ms_out |
uint16_t | g_u16_read_sector |
uint32_t | g_u32_read_addr |
uint8_t | g_u8_sector_size |
uint8_t | host_selected_lun |
uint8_t host_get_lun | ( | void | ) |
This function returns the number of LUNs of the connected mass-storage device.
References data_stage, host_ms_get_max_lun, and Is_host_ms_configured.
Referenced by host_mass_storage_task().
Ctrl_status host_ms_inquiry | ( | void | ) |
This function sends an SCSI INQUIRY command (0x12) to the device.
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, host_get_data(), host_read_10_ram_stop(), host_selected_lun, host_send_data(), Is_host_ms_configured, PIPE_GOOD, SBC_CMD_DIR_IN, and SBC_CMD_INQUIRY.
Referenced by host_mass_storage_task().
uint8_t host_ms_request_sense | ( | void | ) |
This function sends an SCSI REQUEST SENSE command (0x03) to the device.
References buf_cmd, COMMAND_PASSED, CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, CTRL_NO_PRESENT, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, host_get_data(), host_ms_stall_management(), host_read_10_ram_stop(), host_selected_lun, host_send_data(), Is_host_ms_configured, PIPE_GOOD, PIPE_STALL, SBC_ASC_MEDIUM_NOT_PRESENT, SBC_ASC_NOT_READY_TO_READY_CHANGE, SBC_CMD_DIR_IN, SBC_CMD_REQUEST_SENSE, SBC_SENSE_KEY_DATA_PROTECT, SBC_SENSE_KEY_HARDWARE_ERROR, SBC_SENSE_KEY_MEDIUM_ERROR, SBC_SENSE_KEY_NO_SENSE, SBC_SENSE_KEY_NOT_READY, and SBC_SENSE_KEY_UNIT_ATTENTION.
Referenced by host_mass_storage_task(), host_ms_stall_management(), and host_test_unit_ready().
|
static |
This function manages pipe STALLs.
pipe | Pipe for the CLEAR ENDPOINT FEATURE request |
References buf_cmd, g_pipe_ms_in, Host_ack_stall, host_clear_endpoint_feature, host_get_data(), Host_get_pipe_endpoint_number, host_ms_request_sense(), Host_reset_data_toggle, and MSK_EP_DIR.
Referenced by host_ms_request_sense(), host_read_10_extram(), host_read_10_ram(), host_read_10_ram_stop(), host_read_capacity(), host_test_unit_ready(), host_wr_protect(), and host_write_10_extram().
Ctrl_status host_read_10_extram | ( | uint32_t | addr, |
void * | ram, | ||
uint8_t | nb_sector | ||
) |
This function transfers 1 data sector from memory to RAM sector = 512 bytes.
addr | Sector address to start read |
ram | Address of RAM buffer |
nb_sector | number of sector |
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, g_u32_read_addr, g_u8_sector_size, host_get_data(), host_ms_stall_management(), host_read_10_ram(), host_read_10_ram_stop(), HOST_SECTOR_SIZE, host_selected_lun, host_send_data(), Is_host_ms_configured, LSB0W, LSB1W, LSB2W, LSB3W, MSB0W, MSB1W, MSB2W, MSB3W, PIPE_STALL, SBC_CMD_DIR_IN, and SBC_CMD_READ_10.
Referenced by ushell_cmd_perform_extaccess().
Ctrl_status host_read_10_ram | ( | uint32_t | addr, |
void * | ram | ||
) |
This function transfers 1 data sector from memory to RAM sector = 512 bytes.
addr | Sector address to start read |
ram | Address of RAM buffer |
References buf_cmd, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, g_u16_read_sector, g_u32_read_addr, g_u8_sector_size, host_get_data(), host_ms_stall_management(), host_read_10_ram_stop(), host_read_capacity(), HOST_SECTOR_SIZE, host_selected_lun, host_send_data(), Is_host_ms_configured, LSB0W, LSB1W, LSB2W, LSB3W, MSB0W, MSB1W, MSB2W, MSB3W, PIPE_STALL, SBC_CMD_DIR_IN, and SBC_CMD_READ_10.
Referenced by host_read_10_extram().
|
static |
This function terminates the transfer of a physical sector from memory to RAM.
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_u16_read_sector, host_get_data(), host_ms_stall_management(), HOST_SECTOR_SIZE, and PIPE_STALL.
Referenced by host_ms_inquiry(), host_ms_request_sense(), host_read_10_extram(), host_read_10_ram(), host_read_capacity(), host_test_unit_ready(), host_wr_protect(), and host_write_10_extram().
Ctrl_status host_read_capacity | ( | uint8_t | lun, |
uint32_t * | u32_nb_sector | ||
) |
This function returns the address of the last valid sector in the lun.
lun | Logical Unit Number |
u32_nb_sector | Pointer to number of sectors (sector = 512 bytes) |
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, g_u8_sector_size, host_get_data(), host_ms_stall_management(), host_read_10_ram_stop(), host_selected_lun, host_send_data(), Host_set_device_ready, Is_host_ms_configured, PIPE_GOOD, PIPE_STALL, SBC_CMD_DIR_IN, SBC_CMD_READ_CAPACITY_10, and sbc_format_scsi_to_mcu_data.
Referenced by host_mass_storage_task(), and host_read_10_ram().
uint8_t host_read_sector_size | ( | uint8_t | lun | ) |
This function returns the physical sector size of the lun.
lun | Logical Unit Number |
References g_u8_sector_size.
bool host_removal | ( | void | ) |
This function informs about the memory type.
References Is_host_ms_configured.
Ctrl_status host_test_unit_ready | ( | uint8_t | lun | ) |
This function tests memory state, and starts memory initialization.
lun | Logical Unit Number |
References buf_cmd, COMMAND_PASSED, CTRL_BUSY, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, host_get_data(), host_ms_request_sense(), host_ms_stall_management(), host_read_10_ram_stop(), host_selected_lun, host_send_data(), Host_set_device_ready, Is_host_ms_configured, PIPE_GOOD, PIPE_STALL, SBC_CMD_DIR_OUT, and SBC_CMD_TEST_UNIT_READY.
Referenced by host_mass_storage_task().
bool host_wr_protect | ( | uint8_t | lun | ) |
This function returns the write-protected mode Only used by memory removal with a HARDWARE-SPECIFIC write-protected detection.
lun | Logical Unit Number |
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, g_u8_sector_size, host_get_data(), host_ms_stall_management(), host_read_10_ram_stop(), host_selected_lun, host_send_data(), Is_host_ms_configured, PIPE_GOOD, PIPE_STALL, SBC_CMD_DIR_IN, and SBC_CMD_MODE_SENSE_6.
Ctrl_status host_write_10_extram | ( | uint32_t | addr, |
const void * | ram, | ||
uint8_t | nb_sector | ||
) |
This function transfers 1 data sector from RAM to memory sector = 512 bytes.
addr | Sector address to start write |
ram | Address of RAM buffer |
nb_sector | Number of sector |
References buf_cmd, COMMAND_PASSED, CTRL_FAIL, CTRL_GOOD, g_b_read_run, g_pipe_ms_in, g_pipe_ms_out, g_u8_sector_size, host_get_data(), host_ms_stall_management(), host_read_10_ram_stop(), HOST_SECTOR_SIZE, host_selected_lun, host_send_data(), Is_host_ms_configured, LSB0W, LSB1W, LSB2W, LSB3W, MSB0W, MSB1W, MSB2W, MSB3W, PIPE_STALL, SBC_CMD_DIR_OUT, and SBC_CMD_WRITE_10.
Referenced by host_write_10_ram(), and ushell_cmd_perform_extaccess().
Ctrl_status host_write_10_ram | ( | uint32_t | addr, |
const void * | ram | ||
) |
This function transfers 1 data sector from RAM to memory sector = 512 bytes.
addr | Sector address to start write |
ram | Address of RAM buffer |
References host_write_10_extram().
|
static |
uint8_t g_b_read_run = false |
uint8_t g_pipe_ms_in |
uint8_t g_pipe_ms_out |
uint16_t g_u16_read_sector |
Referenced by host_read_10_ram(), and host_read_10_ram_stop().
uint32_t g_u32_read_addr |
Referenced by host_read_10_extram(), and host_read_10_ram().
uint8_t g_u8_sector_size |
uint8_t host_selected_lun |