Prusa MINI Firmware overview
usb_host.c File Reference

: This file implements the USB Host More...

#include "usb_host.h"
#include "usbh_core.h"
#include "usbh_msc.h"
#include "fatfs.h"
#include "dbg.h"
#include <stdbool.h>

Functions

void media_set_inserted (bool inserted)
 
static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id)
 
void MX_USB_HOST_Init (void)
 USB Host initialization function. More...
 

Variables

USBH_HandleTypeDef hUsbHostHS
 
ApplicationTypeDef Appli_state = APPLICATION_IDLE
 

Detailed Description

: This file implements the USB Host

Version
: v1.0_Cube This notice applies to any and all portions of this file that are not between comment pairs USER CODE BEGIN and USER CODE END. Other portions of this file, whether inserted by the user or by software development tools are owned by their respective copyright owners.

Copyright (c) 2019 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ media_set_inserted()

void media_set_inserted ( bool  inserted)
21  {
22  _media_inserted = inserted;
23  CardReader::flag.mounted = true;
24 }
Here is the caller graph for this function:

◆ USBH_UserProcess()

static void USBH_UserProcess ( USBH_HandleTypeDef phost,
uint8_t  id 
)
static
127  {
128  /* USER CODE BEGIN CALL_BACK_1 */
129  switch (id) {
131  break;
132 
135  media_set_inserted(false);
136  f_mount(0, (TCHAR const *)USBHPath, 1); //umount
137  break;
138 
141  FRESULT result = f_mount(&USBHFatFS, (TCHAR const *)USBHPath, 0);
142  if (result == FR_OK)
143  media_set_inserted(true);
144  else {
145  // TODO: inform the user
146  _dbg("disk not mounted; error: %d", result);
147  }
148  break;
149 
152  break;
153 
154  default:
155  break;
156  }
157  /* USER CODE END CALL_BACK_1 */
158 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ hUsbHostHS

USBH_HandleTypeDef hUsbHostHS

◆ Appli_state

TCHAR
char TCHAR
Definition: ff.h:62
HOST_USER_SELECT_CONFIGURATION
#define HOST_USER_SELECT_CONFIGURATION
Definition: usbh_core.h:64
HOST_USER_CLASS_ACTIVE
#define HOST_USER_CLASS_ACTIVE
Definition: usbh_core.h:65
Appli_state
ApplicationTypeDef Appli_state
Definition: usb_host.c:75
HOST_USER_DISCONNECTION
#define HOST_USER_DISCONNECTION
Definition: usbh_core.h:68
APPLICATION_DISCONNECT
Definition: usb_host.h:89
HOST_USER_CONNECTION
#define HOST_USER_CONNECTION
Definition: usbh_core.h:67
_media_inserted
static bool _media_inserted
Definition: Marlin_CardReader.cpp:15
APPLICATION_READY
Definition: usb_host.h:88
USBHFatFS
FATFS USBHFatFS
Definition: fatfs.c:53
_dbg
#define _dbg(...)
Definition: dbg.h:50
FRESULT
FRESULT
Definition: ff.h:214
FR_OK
Definition: ff.h:215
f_mount
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
Definition: ff.c:3248
USBHPath
char USBHPath[4]
Definition: fatfs.c:52
APPLICATION_START
Definition: usb_host.h:87
media_set_inserted
void media_set_inserted(bool inserted)
Definition: Marlin_CardReader.cpp:21