Prusa MINI Firmware overview
USBH_MSC_CORE_Exported_FunctionsPrototype
Collaboration diagram for USBH_MSC_CORE_Exported_FunctionsPrototype:

Functions

uint8_t USBH_MSC_IsReady (USBH_HandleTypeDef *phost)
 USBH_MSC_IsReady The function check if the MSC function is ready. More...
 
int8_t USBH_MSC_GetMaxLUN (USBH_HandleTypeDef *phost)
 USBH_MSC_GetMaxLUN The function return the Max LUN supported. More...
 
uint8_t USBH_MSC_UnitIsReady (USBH_HandleTypeDef *phost, uint8_t lun)
 USBH_MSC_UnitIsReady The function check whether a LUN is ready. More...
 
USBH_StatusTypeDef USBH_MSC_GetLUNInfo (USBH_HandleTypeDef *phost, uint8_t lun, MSC_LUNTypeDef *info)
 USBH_MSC_GetLUNInfo The function return a LUN information. More...
 
USBH_StatusTypeDef USBH_MSC_Read (USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
 USBH_MSC_Read The function performs a Read operation. More...
 
USBH_StatusTypeDef USBH_MSC_Write (USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
 USBH_MSC_Write The function performs a Write operation. More...
 

Detailed Description

Function Documentation

◆ USBH_MSC_IsReady()

uint8_t USBH_MSC_IsReady ( USBH_HandleTypeDef phost)

USBH_MSC_IsReady The function check if the MSC function is ready.

Parameters
phostHost handle
Return values
USBHStatus
618 {
619  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
620 
621  if(phost->gState == HOST_CLASS)
622  {
623  return (MSC_Handle->state == MSC_IDLE);
624  }
625  else
626  {
627  return 0;
628  }
629 }

◆ USBH_MSC_GetMaxLUN()

int8_t USBH_MSC_GetMaxLUN ( USBH_HandleTypeDef phost)

USBH_MSC_GetMaxLUN The function return the Max LUN supported.

Parameters
phostHost handle
Return values
logicalUnit Number supported
638 {
639  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
640 
641  if ((phost->gState == HOST_CLASS) && (MSC_Handle->state == MSC_IDLE))
642  {
643  return MSC_Handle->max_lun;
644  }
645  return 0xFF;
646 }
Here is the call graph for this function:

◆ USBH_MSC_UnitIsReady()

uint8_t USBH_MSC_UnitIsReady ( USBH_HandleTypeDef phost,
uint8_t  lun 
)

USBH_MSC_UnitIsReady The function check whether a LUN is ready.

Parameters
phostHost handle
lunlogical Unit Number
Return values
Lunstatus (0: not ready / 1: ready)
656 {
657  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
658 
659  if(phost->gState == HOST_CLASS)
660  {
661  return (MSC_Handle->unit[lun].error == MSC_OK);
662  }
663  else
664  {
665  return 0;
666  }
667 }
Here is the caller graph for this function:

◆ USBH_MSC_GetLUNInfo()

USBH_StatusTypeDef USBH_MSC_GetLUNInfo ( USBH_HandleTypeDef phost,
uint8_t  lun,
MSC_LUNTypeDef info 
)

USBH_MSC_GetLUNInfo The function return a LUN information.

Parameters
phostHost handle
lunlogical Unit Number
Return values
USBHStatus
677 {
678  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
679  if(phost->gState == HOST_CLASS)
680  {
681  USBH_memcpy(info,&MSC_Handle->unit[lun], sizeof(MSC_LUNTypeDef));
682  return USBH_OK;
683  }
684  else
685  {
686  return USBH_FAIL;
687  }
688 }
Here is the caller graph for this function:

◆ USBH_MSC_Read()

USBH_StatusTypeDef USBH_MSC_Read ( USBH_HandleTypeDef phost,
uint8_t  lun,
uint32_t  address,
uint8_t pbuf,
uint32_t  length 
)

USBH_MSC_Read The function performs a Read operation.

Parameters
phostHost handle
lunlogical Unit Number
addresssector address
pbufpointer to data
lengthnumber of sector to read
Return values
USBHStatus
705 {
706  uint32_t timeout;
707  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
708 
709  if ((phost->device.is_connected == 0) ||
710  (phost->gState != HOST_CLASS) ||
711  (MSC_Handle->unit[lun].state != MSC_IDLE))
712  {
713  return USBH_FAIL;
714  }
715  MSC_Handle->state = MSC_READ;
716  MSC_Handle->unit[lun].state = MSC_READ;
717  MSC_Handle->rw_lun = lun;
718  USBH_MSC_SCSI_Read(phost,
719  lun,
720  address,
721  pbuf,
722  length);
723 
724  timeout = phost->Timer;
725 
726  while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY)
727  {
728  if(((phost->Timer - timeout) > (10000 * length)) || (phost->device.is_connected == 0))
729  {
730  MSC_Handle->state = MSC_IDLE;
731  return USBH_FAIL;
732  }
733  }
734  MSC_Handle->state = MSC_IDLE;
735  return USBH_OK;
736 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_MSC_Write()

USBH_StatusTypeDef USBH_MSC_Write ( USBH_HandleTypeDef phost,
uint8_t  lun,
uint32_t  address,
uint8_t pbuf,
uint32_t  length 
)

USBH_MSC_Write The function performs a Write operation.

Parameters
phostHost handle
lunlogical Unit Number
addresssector address
pbufpointer to data
lengthnumber of sector to write
Return values
USBHStatus
753 {
754  uint32_t timeout;
755  MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
756 
757  if ((phost->device.is_connected == 0) ||
758  (phost->gState != HOST_CLASS) ||
759  (MSC_Handle->unit[lun].state != MSC_IDLE))
760  {
761  return USBH_FAIL;
762  }
763  MSC_Handle->state = MSC_WRITE;
764  MSC_Handle->unit[lun].state = MSC_WRITE;
765  MSC_Handle->rw_lun = lun;
766  USBH_MSC_SCSI_Write(phost,
767  lun,
768  address,
769  pbuf,
770  length);
771 
772  timeout = phost->Timer;
773  while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY)
774  {
775  if(((phost->Timer - timeout) > (10000 * length)) || (phost->device.is_connected == 0))
776  {
777  MSC_Handle->state = MSC_IDLE;
778  return USBH_FAIL;
779  }
780  }
781  MSC_Handle->state = MSC_IDLE;
782  return USBH_OK;
783 }
Here is the call graph for this function:
USBH_MSC_SCSI_Read
USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
USBH_MSC_SCSI_Read Issue Read10 command.
Definition: usbh_msc_scsi.c:384
MSC_LUNTypeDef
Definition: usbh_msc.h:102
MSC_WRITE
Definition: usbh_msc.h:72
_USBH_HandleTypeDef::Timer
__IO uint32_t Timer
Definition: usbh_def.h:461
USBH_ClassTypeDef::pData
void * pData
Definition: usbh_def.h:446
USBH_memcpy
#define USBH_memcpy
Definition: usbh_conf.h:157
MSC_LUNTypeDef::error
MSC_ErrorTypeDef error
Definition: usbh_msc.h:105
USBH_MSC_RdWrProcess
static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_t lun)
USBH_MSC_RdWrProcess The function is for managing state machine for MSC I/O Process.
Definition: usbh_msc.c:523
MSC_OK
Definition: usbh_msc.h:80
USBH_OK
Definition: usbh_def.h:304
_USBH_HandleTypeDef::device
USBH_DeviceTypeDef device
Definition: usbh_def.h:456
_MSC_Process::rw_lun
uint16_t rw_lun
Definition: usbh_msc.h:132
USBH_DeviceTypeDef::is_connected
__IO uint8_t is_connected
Definition: usbh_def.h:427
_MSC_Process::unit
MSC_LUNTypeDef unit[MAX_SUPPORTED_LUN]
Definition: usbh_msc.h:130
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
_MSC_Process::state
MSC_StateTypeDef state
Definition: usbh_msc.h:125
address
UsbDeviceAddress address
Definition: address.h:202
_MSC_Process::max_lun
uint32_t max_lun
Definition: usbh_msc.h:118
USBH_MSC_SCSI_Write
USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost, uint8_t lun, uint32_t address, uint8_t *pbuf, uint32_t length)
USBH_MSC_SCSI_Write Issue write10 command.
Definition: usbh_msc_scsi.c:323
MSC_READ
Definition: usbh_msc.h:71
USBH_FAIL
Definition: usbh_def.h:306
USBH_BUSY
Definition: usbh_def.h:305
MSC_IDLE
Definition: usbh_msc.h:66
length
png_uint_32 length
Definition: png.c:2247
_USBH_HandleTypeDef::pActiveClass
USBH_ClassTypeDef * pActiveClass
Definition: usbh_def.h:458
_USBH_HandleTypeDef::gState
__IO HOST_StateTypeDef gState
Definition: usbh_def.h:452
pbuf
Definition: pbuf.h:142
MSC_LUNTypeDef::state
MSC_StateTypeDef state
Definition: usbh_msc.h:104
HOST_CLASS
Definition: usbh_def.h:338
_MSC_Process
Definition: usbh_msc.h:116
info
uint8_t info[12]
Definition: masstorage.h:54