forked from MarlinFirmware/Marlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix-2.0.x' of git://github.com/MarlinFirmware/Marlin…
… into bugfix-2.0.x
- Loading branch information
Showing
40 changed files
with
596 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] | ||
* | ||
* Based on Sprinter and grbl. | ||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) | ||
|
||
#include "../../inc/MarlinConfig.h" | ||
|
||
#if BOTH(USE_OTG_USB_HOST, USBHOST) | ||
|
||
#include "usb_host.h" | ||
#include "../shared/Marduino.h" | ||
#include "usbh_core.h" | ||
#include "usbh_msc.h" | ||
|
||
USBH_HandleTypeDef hUsbHost; | ||
USBHost usb; | ||
BulkStorage bulk(&usb); | ||
|
||
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) { | ||
switch(id) { | ||
case HOST_USER_SELECT_CONFIGURATION: | ||
//SERIAL_ECHOLNPGM("APPLICATION_SELECT_CONFIGURATION"); | ||
break; | ||
case HOST_USER_DISCONNECTION: | ||
//SERIAL_ECHOLNPGM("APPLICATION_DISCONNECT"); | ||
//usb.setUsbTaskState(USB_STATE_RUNNING); | ||
break; | ||
case HOST_USER_CLASS_ACTIVE: | ||
//SERIAL_ECHOLNPGM("APPLICATION_READY"); | ||
usb.setUsbTaskState(USB_STATE_RUNNING); | ||
break; | ||
case HOST_USER_CONNECTION: | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
bool USBHost::start() { | ||
if (USBH_Init(&hUsbHost, USBH_UserProcess, TERN(USE_USB_HS_IN_FS, HOST_HS, HOST_FS)) != USBH_OK) { | ||
SERIAL_ECHOLNPGM("Error: USBH_Init"); | ||
return false; | ||
} | ||
if (USBH_RegisterClass(&hUsbHost, USBH_MSC_CLASS) != USBH_OK) { | ||
SERIAL_ECHOLNPGM("Error: USBH_RegisterClass"); | ||
return false; | ||
} | ||
if (USBH_Start(&hUsbHost) != USBH_OK) { | ||
SERIAL_ECHOLNPGM("Error: USBH_Start"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
void USBHost::Task() { | ||
USBH_Process(&hUsbHost); | ||
} | ||
|
||
uint8_t USBHost::getUsbTaskState() { | ||
return usb_task_state; | ||
} | ||
|
||
void USBHost::setUsbTaskState(uint8_t state) { | ||
usb_task_state = state; | ||
if (usb_task_state == USB_STATE_RUNNING) { | ||
MSC_LUNTypeDef info; | ||
USBH_MSC_GetLUNInfo(&hUsbHost, usb.lun, &info); | ||
capacity = info.capacity.block_nbr / 2000; | ||
block_size = info.capacity.block_size; | ||
block_count = info.capacity.block_nbr; | ||
// SERIAL_ECHOLNPAIR("info.capacity.block_nbr : %ld\n", info.capacity.block_nbr); | ||
// SERIAL_ECHOLNPAIR("info.capacity.block_size: %d\n", info.capacity.block_size); | ||
// SERIAL_ECHOLNPAIR("capacity : %d MB\n", capacity); | ||
} | ||
}; | ||
|
||
bool BulkStorage::LUNIsGood(uint8_t t) { | ||
return USBH_MSC_IsReady(&hUsbHost) && USBH_MSC_UnitIsReady(&hUsbHost, t); | ||
} | ||
|
||
uint32_t BulkStorage::GetCapacity(uint8_t lun) { | ||
return usb->block_count; | ||
} | ||
|
||
uint16_t BulkStorage::GetSectorSize(uint8_t lun) { | ||
return usb->block_size; | ||
} | ||
|
||
uint8_t BulkStorage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) { | ||
return USBH_MSC_Read(&hUsbHost, lun, addr, buf, blocks) != USBH_OK; | ||
} | ||
|
||
uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { | ||
return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast <uint8_t*>(buf), blocks) != USBH_OK; | ||
} | ||
|
||
#endif // USE_OTG_USB_HOST && USBHOST | ||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Marlin 3D Printer Firmware | ||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] | ||
* | ||
* Based on Sprinter and grbl. | ||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#pragma once | ||
|
||
<<<<<<< HEAD:Marlin/src/module/thermistor/thermistor_503.h | ||
// Zonestar (Z8XM2) Heated Bed thermistor. Added By AvanOsch | ||
// These are taken from the Zonestar settings in original Repetier firmware: Z8XM2_ZRIB_LCD12864_V51.zip | ||
const temp_entry_t temptable_503[] PROGMEM = { | ||
{ OV( 12), 300 }, | ||
{ OV( 27), 270 }, | ||
{ OV( 47), 250 }, | ||
{ OV( 68), 230 }, | ||
{ OV( 99), 210 }, | ||
{ OV( 120), 200 }, | ||
{ OV( 141), 190 }, | ||
{ OV( 171), 180 }, | ||
{ OV( 201), 170 }, | ||
{ OV( 261), 160 }, | ||
{ OV( 321), 150 }, | ||
{ OV( 401), 140 }, | ||
{ OV( 451), 130 }, | ||
{ OV( 551), 120 }, | ||
{ OV( 596), 110 }, | ||
{ OV( 626), 105 }, | ||
{ OV( 666), 100 }, | ||
{ OV( 697), 90 }, | ||
{ OV( 717), 85 }, | ||
{ OV( 798), 69 }, | ||
{ OV( 819), 65 }, | ||
{ OV( 870), 55 }, | ||
{ OV( 891), 51 }, | ||
{ OV( 922), 39 }, | ||
{ OV( 968), 28 }, | ||
{ OV( 980), 23 }, | ||
{ OV( 991), 17 }, | ||
{ OV( 1001), 9 }, | ||
{ OV(1021), -27 }, | ||
{ OV(1023), -200} | ||
}; | ||
======= | ||
#include <stdint.h> | ||
|
||
typedef enum { | ||
USB_STATE_INIT, | ||
USB_STATE_ERROR, | ||
USB_STATE_RUNNING, | ||
} usb_state_t; | ||
|
||
class USBHost { | ||
public: | ||
bool start(); | ||
void Task(); | ||
uint8_t getUsbTaskState(); | ||
void setUsbTaskState(uint8_t state); | ||
uint8_t regRd(uint8_t reg) { return 0x0; }; | ||
uint8_t usb_task_state = USB_STATE_INIT; | ||
uint8_t lun = 0; | ||
uint32_t capacity = 0; | ||
uint16_t block_size = 0; | ||
uint32_t block_count = 0; | ||
}; | ||
|
||
class BulkStorage { | ||
public: | ||
BulkStorage(USBHost *usb) : usb(usb) {}; | ||
|
||
bool LUNIsGood(uint8_t t); | ||
uint32_t GetCapacity(uint8_t lun); | ||
uint16_t GetSectorSize(uint8_t lun); | ||
uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); | ||
uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf); | ||
|
||
USBHost *usb; | ||
}; | ||
|
||
extern USBHost usb; | ||
extern BulkStorage bulk; | ||
>>>>>>> 4ad633bae235f0a47972d6d7873e614b8286d914:Marlin/src/HAL/STM32/usb_host.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.