USB Host Shield 2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BulkOnly Class Reference

#include <masstorage.h>

Inheritance diagram for BulkOnly:
Inheritance graph
[legend]
Collaboration diagram for BulkOnly:
Collaboration graph
[legend]

Public Member Functions

 BulkOnly (USB *p)
 
uint8_t GetLastUsbError ()
 
uint8_t GetbMaxLUN ()
 
uint8_t GetbTheLUN ()
 
bool WriteProtected (uint8_t lun)
 
uint8_t MediaCTL (uint8_t lun, uint8_t ctl)
 
uint8_t Read (uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf)
 
uint8_t Read (uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser *prs)
 
uint8_t Write (uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t *buf)
 
uint8_t LockMedia (uint8_t lun, uint8_t lock)
 
bool LUNIsGood (uint8_t lun)
 
uint32_t GetCapacity (uint8_t lun)
 
uint16_t GetSectorSize (uint8_t lun)
 
uint8_t Init (uint8_t parent, uint8_t port, bool lowspeed)
 
uint8_t ConfigureDevice (uint8_t parent, uint8_t port, bool lowspeed)
 
uint8_t Release ()
 
uint8_t Poll ()
 
virtual uint8_t GetAddress ()
 
void EndpointXtract (uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
 
virtual bool DEVCLASSOK (uint8_t klass)
 
uint8_t SCSITransaction6 (CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir)
 
uint8_t SCSITransaction10 (CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir)
 
- Public Member Functions inherited from USBDeviceConfig
virtual void ResetHubPort (uint8_t port)
 
virtual bool VIDPIDOK (uint16_t vid, uint16_t pid)
 
virtual bool DEVSUBCLASSOK (uint8_t subklass)
 

Protected Member Functions

void PrintEndpointDescriptor (const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
 
virtual uint8_t OnInit ()
 

Protected Attributes

USBpUsb
 
uint8_t bAddress
 
uint8_t bConfNum
 
uint8_t bIface
 
uint8_t bNumEP
 
uint32_t qNextPollTime
 
bool bPollEnable
 
EpInfo epInfo [MASS_MAX_ENDPOINTS]
 
uint32_t dCBWTag
 
uint8_t bLastUsbError
 
uint8_t bMaxLUN
 
uint8_t bTheLUN
 
uint32_t CurrentCapacity [MASS_MAX_SUPPORTED_LUN]
 
uint16_t CurrentSectorSize [MASS_MAX_SUPPORTED_LUN]
 
bool LUNOk [MASS_MAX_SUPPORTED_LUN]
 
bool WriteOk [MASS_MAX_SUPPORTED_LUN]
 

Static Protected Attributes

static const uint8_t epDataInIndex = 1
 
static const uint8_t epDataOutIndex = 2
 
static const uint8_t epInterruptInIndex = 3
 

Detailed Description

Definition at line 469 of file masstorage.h.

Constructor & Destructor Documentation

◆ BulkOnly()

BulkOnly::BulkOnly ( USB p)

Definition at line 229 of file masstorage.cpp.

Member Function Documentation

◆ PrintEndpointDescriptor()

void BulkOnly::PrintEndpointDescriptor ( const USB_ENDPOINT_DESCRIPTOR ep_ptr)
protected
Parameters
ep_ptr

Definition at line 1220 of file masstorage.cpp.

◆ OnInit()

virtual uint8_t BulkOnly::OnInit ( )
inlineprotectedvirtual

Definition at line 499 of file masstorage.h.

◆ GetLastUsbError()

uint8_t BulkOnly::GetLastUsbError ( )
inline

Definition at line 505 of file masstorage.h.

◆ GetbMaxLUN()

uint8_t BulkOnly::GetbMaxLUN ( )
inline

Definition at line 509 of file masstorage.h.

◆ GetbTheLUN()

uint8_t BulkOnly::GetbTheLUN ( )
inline

Definition at line 513 of file masstorage.h.

◆ WriteProtected()

bool BulkOnly::WriteProtected ( uint8_t  lun)

Test if LUN is write protected

Parameters
lunLogical Unit Number
Returns
cached status of write protect switch

Definition at line 77 of file masstorage.cpp.

◆ MediaCTL()

uint8_t BulkOnly::MediaCTL ( uint8_t  lun,
uint8_t  ctl 
)

Media control, for spindle motor and media tray or door. This includes CDROM, TAPE and anything with a media loader.

Parameters
lunLogical Unit Number
ctl0x00 Stop Motor, 0x01 Start Motor, 0x02 Eject Media, 0x03 Load Media
Returns
0 on success

Definition at line 137 of file masstorage.cpp.

◆ Read() [1/2]

uint8_t BulkOnly::Read ( uint8_t  lun,
uint32_t  addr,
uint16_t  bsize,
uint8_t  blocks,
uint8_t *  buf 
)

Read data from media

Parameters
lunLogical Unit Number
addrLBA address on media to read
bsizesize of a block (we should probably use the cached size)
blockshow many blocks to read
bufmemory that is able to hold the requested data
Returns
0 on success

Definition at line 161 of file masstorage.cpp.

◆ Read() [2/2]

uint8_t BulkOnly::Read ( uint8_t  lun,
uint32_t  addr,
uint16_t  bsize,
uint8_t  blocks,
USBReadParser prs 
)

Definition at line 1247 of file masstorage.cpp.

◆ Write()

uint8_t BulkOnly::Write ( uint8_t  lun,
uint32_t  addr,
uint16_t  bsize,
uint8_t  blocks,
const uint8_t *  buf 
)

Write data to media

Parameters
lunLogical Unit Number
addrLBA address on media to write
bsizesize of a block (we should probably use the cached size)
blockshow many blocks to write
bufmemory that contains the data to write
Returns
0 on success

Definition at line 195 of file masstorage.cpp.

◆ LockMedia()

uint8_t BulkOnly::LockMedia ( uint8_t  lun,
uint8_t  lock 
)

Lock or Unlock the tray or door on device. Caution: Some devices with buggy firmware will lock up.

Parameters
lunLogical Unit Number
lock1 to lock, 0 to unlock
Returns

Definition at line 121 of file masstorage.cpp.

◆ LUNIsGood()

bool BulkOnly::LUNIsGood ( uint8_t  lun)

Test if LUN is ready for use

Parameters
lunLogical Unit Number
Returns
true if LUN is ready for use

Definition at line 67 of file masstorage.cpp.

◆ GetCapacity()

uint32_t BulkOnly::GetCapacity ( uint8_t  lun)

Get the capacity of the media

Parameters
lunLogical Unit Number
Returns
media capacity

Definition at line 43 of file masstorage.cpp.

◆ GetSectorSize()

uint16_t BulkOnly::GetSectorSize ( uint8_t  lun)

Get the sector (block) size used on the media

Parameters
lunLogical Unit Number
Returns
media sector size

Definition at line 55 of file masstorage.cpp.

◆ Init()

uint8_t BulkOnly::Init ( uint8_t  parent,
uint8_t  port,
bool  lowspeed 
)
virtual
Parameters
parent(not used)
port(not used)
lowspeedtrue if device is low speed
Returns
0 for success

Reimplemented from USBDeviceConfig.

Definition at line 333 of file masstorage.cpp.

◆ ConfigureDevice()

uint8_t BulkOnly::ConfigureDevice ( uint8_t  parent,
uint8_t  port,
bool  lowspeed 
)
virtual

USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET == success We need to standardize either the rcode, or change the API to return values so a signal that additional actions are required can be produced. Some of these codes do exist already.

TECHNICAL: We could do most of this code elsewhere, with the exception of checking the class instance. Doing so would save some program memory when using multiple drivers.

Parameters
parentUSB address of parent
portaddress of port on parent
lowspeedtrue if device is low speed
Returns

Reimplemented from USBDeviceConfig.

Definition at line 258 of file masstorage.cpp.

◆ Release()

uint8_t BulkOnly::Release ( )
virtual

For driver use only.

Returns

Reimplemented from USBDeviceConfig.

Definition at line 598 of file masstorage.cpp.

◆ Poll()

uint8_t BulkOnly::Poll ( )
virtual

For driver use only.

Returns

Reimplemented from USBDeviceConfig.

Definition at line 676 of file masstorage.cpp.

◆ GetAddress()

virtual uint8_t BulkOnly::GetAddress ( )
inlinevirtual

Reimplemented from USBDeviceConfig.

Definition at line 535 of file masstorage.h.

◆ EndpointXtract()

void BulkOnly::EndpointXtract ( uint8_t  conf,
uint8_t  iface,
uint8_t  alt,
uint8_t  proto,
const USB_ENDPOINT_DESCRIPTOR pep 
)
virtual

For driver use only.

Parameters
conf
iface
alt
proto
pep

Reimplemented from UsbConfigXtracter.

Definition at line 550 of file masstorage.cpp.

◆ DEVCLASSOK()

virtual bool BulkOnly::DEVCLASSOK ( uint8_t  klass)
inlinevirtual

Reimplemented from USBDeviceConfig.

Definition at line 542 of file masstorage.h.

◆ SCSITransaction6()

uint8_t BulkOnly::SCSITransaction6 ( CDB6_t cdb,
uint16_t  buf_size,
void *  buf,
uint8_t  dir 
)

Wrap and execute a SCSI CDB with length of 6

Parameters
cdbCDB to execute
buf_sizeSize of expected transaction
bufBuffer
dirMASS_CMD_DIR_IN | MASS_CMD_DIR_OUT
Returns

Definition at line 90 of file masstorage.cpp.

◆ SCSITransaction10()

uint8_t BulkOnly::SCSITransaction10 ( CDB10_t cdb,
uint16_t  buf_size,
void *  buf,
uint8_t  dir 
)

Wrap and execute a SCSI CDB with length of 10

Parameters
cdbCDB to execute
buf_sizeSize of expected transaction
bufBuffer
dirMASS_CMD_DIR_IN | MASS_CMD_DIR_OUT
Returns

Definition at line 106 of file masstorage.cpp.

Member Data Documentation

◆ epDataInIndex

const uint8_t BulkOnly::epDataInIndex = 1
staticprotected

Definition at line 471 of file masstorage.h.

◆ epDataOutIndex

const uint8_t BulkOnly::epDataOutIndex = 2
staticprotected

Definition at line 472 of file masstorage.h.

◆ epInterruptInIndex

const uint8_t BulkOnly::epInterruptInIndex = 3
staticprotected

Definition at line 473 of file masstorage.h.

◆ pUsb

USB* BulkOnly::pUsb
protected

Definition at line 475 of file masstorage.h.

◆ bAddress

uint8_t BulkOnly::bAddress
protected

Definition at line 476 of file masstorage.h.

◆ bConfNum

uint8_t BulkOnly::bConfNum
protected

Definition at line 477 of file masstorage.h.

◆ bIface

uint8_t BulkOnly::bIface
protected

Definition at line 478 of file masstorage.h.

◆ bNumEP

uint8_t BulkOnly::bNumEP
protected

Definition at line 479 of file masstorage.h.

◆ qNextPollTime

uint32_t BulkOnly::qNextPollTime
protected

Definition at line 480 of file masstorage.h.

◆ bPollEnable

bool BulkOnly::bPollEnable
protected

Definition at line 481 of file masstorage.h.

◆ epInfo

EpInfo BulkOnly::epInfo[MASS_MAX_ENDPOINTS]
protected

Definition at line 483 of file masstorage.h.

◆ dCBWTag

uint32_t BulkOnly::dCBWTag
protected

Definition at line 485 of file masstorage.h.

◆ bLastUsbError

uint8_t BulkOnly::bLastUsbError
protected

Definition at line 487 of file masstorage.h.

◆ bMaxLUN

uint8_t BulkOnly::bMaxLUN
protected

Definition at line 488 of file masstorage.h.

◆ bTheLUN

uint8_t BulkOnly::bTheLUN
protected

Definition at line 489 of file masstorage.h.

◆ CurrentCapacity

uint32_t BulkOnly::CurrentCapacity[MASS_MAX_SUPPORTED_LUN]
protected

Definition at line 490 of file masstorage.h.

◆ CurrentSectorSize

uint16_t BulkOnly::CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]
protected

Definition at line 491 of file masstorage.h.

◆ LUNOk

bool BulkOnly::LUNOk[MASS_MAX_SUPPORTED_LUN]
protected

Definition at line 492 of file masstorage.h.

◆ WriteOk

bool BulkOnly::WriteOk[MASS_MAX_SUPPORTED_LUN]
protected

Definition at line 493 of file masstorage.h.


The documentation for this class was generated from the following files: