🎨 Misc. USB flash code cleanup
This commit is contained in:
parent
2dc4c642e7
commit
2f3960904e
@ -61,10 +61,8 @@
|
|||||||
#define USB_NO_TEST_UNIT_READY // Required for removable media adapter
|
#define USB_NO_TEST_UNIT_READY // Required for removable media adapter
|
||||||
#define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically
|
#define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically
|
||||||
|
|
||||||
// Workarounds for keeping Marlin's watchdog timer from barking...
|
// Workarounds to keep Marlin's watchdog timer from barking...
|
||||||
void marlin_yield() {
|
void marlin_yield() { thermalManager.manage_heater(); }
|
||||||
thermalManager.manage_heater();
|
|
||||||
}
|
|
||||||
#define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield();
|
#define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield();
|
||||||
#define delay(x) safe_delay(x)
|
#define delay(x) safe_delay(x)
|
||||||
|
|
||||||
@ -82,6 +80,7 @@
|
|||||||
|
|
||||||
#define UHS_START (usb.Init() == 0)
|
#define UHS_START (usb.Init() == 0)
|
||||||
#define UHS_STATE(state) UHS_USB_HOST_STATE_##state
|
#define UHS_STATE(state) UHS_USB_HOST_STATE_##state
|
||||||
|
|
||||||
#elif ENABLED(USE_OTG_USB_HOST)
|
#elif ENABLED(USE_OTG_USB_HOST)
|
||||||
|
|
||||||
#if HAS_SD_HOST_DRIVE
|
#if HAS_SD_HOST_DRIVE
|
||||||
@ -93,7 +92,9 @@
|
|||||||
#define UHS_START usb.start()
|
#define UHS_START usb.start()
|
||||||
#define rREVISION 0
|
#define rREVISION 0
|
||||||
#define UHS_STATE(state) USB_STATE_##state
|
#define UHS_STATE(state) USB_STATE_##state
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "lib-uhs2/Usb.h"
|
#include "lib-uhs2/Usb.h"
|
||||||
#include "lib-uhs2/masstorage.h"
|
#include "lib-uhs2/masstorage.h"
|
||||||
|
|
||||||
@ -102,6 +103,7 @@
|
|||||||
|
|
||||||
#define UHS_START usb.start()
|
#define UHS_START usb.start()
|
||||||
#define UHS_STATE(state) USB_STATE_##state
|
#define UHS_STATE(state) USB_STATE_##state
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Sd2Card_FlashDrive.h"
|
#include "Sd2Card_FlashDrive.h"
|
||||||
@ -271,11 +273,11 @@ bool DiskIODriver_USBFlash::init(const uint8_t, const pin_t) {
|
|||||||
if (!isInserted()) return false;
|
if (!isInserted()) return false;
|
||||||
|
|
||||||
#if USB_DEBUG >= 1
|
#if USB_DEBUG >= 1
|
||||||
const uint32_t sectorSize = bulk.GetSectorSize(0);
|
const uint32_t sectorSize = bulk.GetSectorSize(0);
|
||||||
if (sectorSize != 512) {
|
if (sectorSize != 512) {
|
||||||
SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize);
|
SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USB_DEBUG >= 3
|
#if USB_DEBUG >= 3
|
||||||
|
@ -27,19 +27,18 @@
|
|||||||
|
|
||||||
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
|
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
|
||||||
|
|
||||||
|
#if !PINS_EXIST(USB_CS, USB_INTR)
|
||||||
|
#error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined."
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "usbhost.h"
|
#include "usbhost.h"
|
||||||
|
|
||||||
uint8_t MAX3421e::vbusState = 0;
|
uint8_t MAX3421e::vbusState = 0;
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
void MAX3421e::cs() {
|
void MAX3421e::cs() { WRITE(USB_CS_PIN, LOW); }
|
||||||
WRITE(USB_CS_PIN,0);
|
void MAX3421e::ncs() { WRITE(USB_CS_PIN, HIGH); }
|
||||||
}
|
|
||||||
|
|
||||||
void MAX3421e::ncs() {
|
|
||||||
WRITE(USB_CS_PIN,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write single byte into MAX3421 register
|
// write single byte into MAX3421 register
|
||||||
void MAX3421e::regWr(uint8_t reg, uint8_t data) {
|
void MAX3421e::regWr(uint8_t reg, uint8_t data) {
|
||||||
@ -76,8 +75,8 @@ uint8_t MAX3421e::regRd(uint8_t reg) {
|
|||||||
ncs();
|
ncs();
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
// multiple-byte register read
|
|
||||||
|
|
||||||
|
// multiple-byte register read
|
||||||
// return a pointer to a memory position after last read
|
// return a pointer to a memory position after last read
|
||||||
uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
||||||
cs();
|
cs();
|
||||||
@ -86,8 +85,8 @@ uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
|||||||
ncs();
|
ncs();
|
||||||
return data_p;
|
return data_p;
|
||||||
}
|
}
|
||||||
// GPIO read. See gpioWr for explanation
|
|
||||||
|
|
||||||
|
// GPIO read. See gpioWr for explanation
|
||||||
// GPIN pins are in high nybbles of IOPINS1, IOPINS2
|
// GPIN pins are in high nybbles of IOPINS1, IOPINS2
|
||||||
uint8_t MAX3421e::gpioRd() {
|
uint8_t MAX3421e::gpioRd() {
|
||||||
return (regRd(rIOPINS2) & 0xF0) | // pins 4-7, clean lower nybble
|
return (regRd(rIOPINS2) & 0xF0) | // pins 4-7, clean lower nybble
|
||||||
|
Loading…
Reference in New Issue
Block a user