Apply #pragma once, misc cleanup (#12322)
* Apply #pragma once in headers * Adjust some thermistors formatting * Misc cleanup and formatting
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -31,8 +32,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SD2CARD_H_
|
||||
#define _SD2CARD_H_
|
||||
|
||||
#include "SdFatConfig.h"
|
||||
#include "SdInfo.h"
|
||||
@ -202,5 +201,3 @@ class Sd2Card {
|
||||
bool waitNotBusy(const millis_t timeout_ms);
|
||||
bool writeData(uint8_t token, const uint8_t* src);
|
||||
};
|
||||
|
||||
#endif // _SD2CARD_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -31,9 +32,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SDBASEFILE_H_
|
||||
#define _SDBASEFILE_H_
|
||||
|
||||
|
||||
#include "SdFatConfig.h"
|
||||
#include "SdVolume.h"
|
||||
@ -387,5 +385,3 @@ class SdBaseFile {
|
||||
bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
|
||||
dir_t* readDirCache();
|
||||
};
|
||||
|
||||
#endif // _SDBASEFILE_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SdFatConfig.h
|
||||
@ -28,12 +29,8 @@
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
|
||||
#ifndef _SDFATCONFIG_H_
|
||||
#define _SDFATCONFIG_H_
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
|
||||
/**
|
||||
* To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
|
||||
*
|
||||
@ -113,5 +110,3 @@
|
||||
|
||||
// Total bytes needed to store a single long filename
|
||||
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH * MAX_VFAT_ENTRIES + 1)
|
||||
|
||||
#endif // _SDFATCONFIG_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -31,8 +32,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef SDFATSTRUCTS_H
|
||||
#define SDFATSTRUCTS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -613,5 +612,3 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
|
||||
static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
|
||||
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
|
||||
}
|
||||
|
||||
#endif // SDFATSTRUCTS_H
|
||||
|
@ -32,6 +32,7 @@
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
#include "SdFatUtil.h"
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Amount of free RAM
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Arduino SdFat Library
|
||||
@ -26,10 +27,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SDFATUTIL_H_
|
||||
#define _SDFATUTIL_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -41,5 +38,3 @@ namespace SdFatUtil {
|
||||
}
|
||||
|
||||
using namespace SdFatUtil; // NOLINT
|
||||
|
||||
#endif // _SDFATUTIL_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -31,8 +32,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SDFILE_H_
|
||||
#define _SDFILE_H_
|
||||
|
||||
#include "SdBaseFile.h"
|
||||
|
||||
@ -58,5 +57,3 @@ class SdFile : public SdBaseFile/*, public Print*/ {
|
||||
void write_P(PGM_P str);
|
||||
void writeln_P(PGM_P str);
|
||||
};
|
||||
|
||||
#endif // _SDFILE_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Arduino Sd2Card Library
|
||||
@ -26,8 +27,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SDINFO_H_
|
||||
#define _SDINFO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -264,5 +263,3 @@ union csd_t {
|
||||
csd1_t v1;
|
||||
csd2_t v2;
|
||||
};
|
||||
|
||||
#endif // _SDINFO_H_
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
@ -31,8 +32,6 @@
|
||||
*
|
||||
* This file is part of the Arduino Sd2Card Library
|
||||
*/
|
||||
#ifndef _SDVOLUME_H_
|
||||
#define _SDVOLUME_H_
|
||||
|
||||
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
|
||||
#include "usb_flashdrive/Sd2Card_FlashDrive.h"
|
||||
@ -195,5 +194,3 @@ class SdVolume {
|
||||
bool readBlock(uint32_t block, uint8_t* dst) { return sdCard_->readBlock(block, dst); }
|
||||
bool writeBlock(uint32_t block, const uint8_t* dst) { return sdCard_->writeBlock(block, dst); }
|
||||
};
|
||||
|
||||
#endif // _SDVOLUME_H_
|
||||
|
@ -19,15 +19,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief Sd2Card class for V2 SD/SDHC cards
|
||||
*/
|
||||
|
||||
#ifndef _SD2CARD_FLASHDRIVE_H_
|
||||
#define _SD2CARD_FLASHDRIVE_H_
|
||||
|
||||
/* Uncomment USB_DEBUG to enable debugging.
|
||||
* 1 - basic debugging and bounds checking
|
||||
* 2 - print each block access
|
||||
@ -99,5 +97,3 @@ class Sd2Card {
|
||||
uint32_t cardSize();
|
||||
static bool isInserted();
|
||||
};
|
||||
|
||||
#endif // _SD2CARD_FLASHDRIVE_H_
|
||||
|
@ -26,8 +26,7 @@ e-mail : support@circuitsathome.com
|
||||
#error "Never include UsbCore.h directly; include Usb.h instead"
|
||||
#endif
|
||||
|
||||
#ifndef USBCORE_H
|
||||
#define USBCORE_H
|
||||
#pragma once
|
||||
|
||||
// Not used anymore? If anyone uses this, please let us know so that this may be
|
||||
// moved to the proper place, settings.h.
|
||||
@ -137,68 +136,68 @@ typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega
|
||||
class USBDeviceConfig {
|
||||
public:
|
||||
|
||||
virtual uint8_t Init(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) {
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t Init(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint8_t ConfigureDevice(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) {
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t ConfigureDevice(uint8_t parent __attribute__((unused)), uint8_t port __attribute__((unused)), bool lowspeed __attribute__((unused))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint8_t Release() {
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t Release() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint8_t Poll() {
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t Poll() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return 0;
|
||||
}
|
||||
virtual uint8_t GetAddress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void ResetHubPort(uint8_t port __attribute__((unused))) {
|
||||
return;
|
||||
} // Note used for hubs only!
|
||||
virtual void ResetHubPort(uint8_t port __attribute__((unused))) {
|
||||
return;
|
||||
} // Note used for hubs only!
|
||||
|
||||
virtual bool VIDPIDOK(uint16_t vid __attribute__((unused)), uint16_t pid __attribute__((unused))) {
|
||||
return false;
|
||||
}
|
||||
virtual bool VIDPIDOK(uint16_t vid __attribute__((unused)), uint16_t pid __attribute__((unused))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool DEVCLASSOK(uint8_t klass __attribute__((unused))) {
|
||||
return false;
|
||||
}
|
||||
virtual bool DEVCLASSOK(uint8_t klass __attribute__((unused))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool DEVSUBCLASSOK(uint8_t subklass __attribute__((unused))) {
|
||||
return true;
|
||||
}
|
||||
virtual bool DEVSUBCLASSOK(uint8_t subklass __attribute__((unused))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* USB Setup Packet Structure */
|
||||
typedef struct {
|
||||
|
||||
union { // offset description
|
||||
uint8_t bmRequestType; // 0 Bit-map of request type
|
||||
union { // offset description
|
||||
uint8_t bmRequestType; // 0 Bit-map of request type
|
||||
|
||||
struct {
|
||||
uint8_t recipient : 5; // Recipient of the request
|
||||
uint8_t type : 2; // Type of request
|
||||
uint8_t direction : 1; // Direction of data X-fer
|
||||
} __attribute__((packed));
|
||||
} ReqType_u;
|
||||
uint8_t bRequest; // 1 Request
|
||||
struct {
|
||||
uint8_t recipient : 5; // Recipient of the request
|
||||
uint8_t type : 2; // Type of request
|
||||
uint8_t direction : 1; // Direction of data X-fer
|
||||
} __attribute__((packed));
|
||||
} ReqType_u;
|
||||
uint8_t bRequest; // 1 Request
|
||||
|
||||
union {
|
||||
uint16_t wValue; // 2 Depends on bRequest
|
||||
union {
|
||||
uint16_t wValue; // 2 Depends on bRequest
|
||||
|
||||
struct {
|
||||
uint8_t wValueLo;
|
||||
uint8_t wValueHi;
|
||||
} __attribute__((packed));
|
||||
} wVal_u;
|
||||
uint16_t wIndex; // 4 Depends on bRequest
|
||||
uint16_t wLength; // 6 Depends on bRequest
|
||||
struct {
|
||||
uint8_t wValueLo;
|
||||
uint8_t wValueHi;
|
||||
} __attribute__((packed));
|
||||
} wVal_u;
|
||||
uint16_t wIndex; // 4 Depends on bRequest
|
||||
uint16_t wLength; // 6 Depends on bRequest
|
||||
} __attribute__((packed)) SETUP_PKT, *PSETUP_PKT;
|
||||
|
||||
|
||||
@ -207,108 +206,106 @@ typedef struct {
|
||||
|
||||
class USBReadParser {
|
||||
public:
|
||||
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0;
|
||||
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0;
|
||||
};
|
||||
|
||||
class USB : public MAX3421E {
|
||||
AddressPoolImpl<USB_NUMDEVICES> addrPool;
|
||||
USBDeviceConfig* devConfig[USB_NUMDEVICES];
|
||||
uint8_t bmHubPre;
|
||||
AddressPoolImpl<USB_NUMDEVICES> addrPool;
|
||||
USBDeviceConfig* devConfig[USB_NUMDEVICES];
|
||||
uint8_t bmHubPre;
|
||||
|
||||
public:
|
||||
USB(void);
|
||||
USB(void);
|
||||
|
||||
void SetHubPreMask() {
|
||||
bmHubPre |= bmHUBPRE;
|
||||
};
|
||||
void SetHubPreMask() {
|
||||
bmHubPre |= bmHUBPRE;
|
||||
};
|
||||
|
||||
void ResetHubPreMask() {
|
||||
bmHubPre &= (~bmHUBPRE);
|
||||
};
|
||||
void ResetHubPreMask() {
|
||||
bmHubPre &= (~bmHUBPRE);
|
||||
};
|
||||
|
||||
AddressPool& GetAddressPool() {
|
||||
return (AddressPool&)addrPool;
|
||||
};
|
||||
AddressPool& GetAddressPool() {
|
||||
return (AddressPool&)addrPool;
|
||||
};
|
||||
|
||||
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev) {
|
||||
for(uint8_t i = 0; i < USB_NUMDEVICES; i++) {
|
||||
if(!devConfig[i]) {
|
||||
devConfig[i] = pdev;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS;
|
||||
};
|
||||
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev) {
|
||||
for(uint8_t i = 0; i < USB_NUMDEVICES; i++) {
|
||||
if(!devConfig[i]) {
|
||||
devConfig[i] = pdev;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS;
|
||||
};
|
||||
|
||||
void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) {
|
||||
addrPool.ForEachUsbDevice(pfunc);
|
||||
};
|
||||
uint8_t getUsbTaskState(void);
|
||||
void setUsbTaskState(uint8_t state);
|
||||
void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) {
|
||||
addrPool.ForEachUsbDevice(pfunc);
|
||||
};
|
||||
uint8_t getUsbTaskState(void);
|
||||
void setUsbTaskState(uint8_t state);
|
||||
|
||||
EpInfo* getEpInfoEntry(uint8_t addr, uint8_t ep);
|
||||
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr);
|
||||
EpInfo* getEpInfoEntry(uint8_t addr, uint8_t ep);
|
||||
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr);
|
||||
|
||||
/* Control requests */
|
||||
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr);
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr);
|
||||
/* Control requests */
|
||||
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr);
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr);
|
||||
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p);
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p);
|
||||
|
||||
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr);
|
||||
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr);
|
||||
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value);
|
||||
/**/
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction);
|
||||
uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval = 0);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
|
||||
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit);
|
||||
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr);
|
||||
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr);
|
||||
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value);
|
||||
/**/
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction);
|
||||
uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval = 0);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
|
||||
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit);
|
||||
|
||||
void Task(void);
|
||||
void Task(void);
|
||||
|
||||
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t ReleaseDevice(uint8_t addr);
|
||||
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t ReleaseDevice(uint8_t addr);
|
||||
|
||||
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p);
|
||||
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p);
|
||||
|
||||
private:
|
||||
void init();
|
||||
uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit);
|
||||
uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data);
|
||||
uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0);
|
||||
uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed);
|
||||
void init();
|
||||
uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit);
|
||||
uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data);
|
||||
uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0);
|
||||
uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed);
|
||||
};
|
||||
|
||||
#if 0 //defined(USB_METHODS_INLINE)
|
||||
//get device descriptor
|
||||
|
||||
inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr));
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr));
|
||||
}
|
||||
//get configuration descriptor
|
||||
|
||||
inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr));
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr));
|
||||
}
|
||||
//get string descriptor
|
||||
|
||||
inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr));
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr));
|
||||
}
|
||||
//set address
|
||||
|
||||
inline uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) {
|
||||
return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL));
|
||||
return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL));
|
||||
}
|
||||
//set configuration
|
||||
|
||||
inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL));
|
||||
return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL));
|
||||
}
|
||||
|
||||
#endif // defined(USB_METHODS_INLINE)
|
||||
|
||||
#endif /* USBCORE_H */
|
||||
|
@ -26,8 +26,7 @@ e-mail : support@circuitsathome.com
|
||||
#error "Never include macros.h directly; include Usb.h instead"
|
||||
#endif
|
||||
|
||||
#ifndef MACROS_H
|
||||
#define MACROS_H
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HANDY MACROS
|
||||
@ -85,5 +84,3 @@ e-mail : support@circuitsathome.com
|
||||
#define USBTRACE1(s,l) (Notify(PSTR(s), l))
|
||||
#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))
|
||||
#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l))
|
||||
|
||||
#endif /* MACROS_H */
|
||||
|
@ -22,12 +22,11 @@ Web : http://www.circuitsathome.com
|
||||
e-mail : support@circuitsathome.com
|
||||
*/
|
||||
|
||||
#if !defined(__MASSTORAGE_H__)
|
||||
#define __MASSTORAGE_H__
|
||||
#pragma once
|
||||
|
||||
// Cruft removal, makes driver smaller, faster.
|
||||
#ifndef MS_WANT_PARSER
|
||||
#define MS_WANT_PARSER 0
|
||||
#define MS_WANT_PARSER 0
|
||||
#endif
|
||||
|
||||
#include "Usb.h"
|
||||
@ -184,395 +183,394 @@ e-mail : support@circuitsathome.com
|
||||
#define MASS_MAX_ENDPOINTS 3
|
||||
|
||||
struct Capacity {
|
||||
uint8_t data[8];
|
||||
//uint32_t dwBlockAddress;
|
||||
//uint32_t dwBlockLength;
|
||||
uint8_t data[8];
|
||||
//uint32_t dwBlockAddress;
|
||||
//uint32_t dwBlockLength;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct BASICCDB {
|
||||
uint8_t Opcode;
|
||||
uint8_t Opcode;
|
||||
|
||||
unsigned unused : 5;
|
||||
unsigned LUN : 3;
|
||||
unsigned unused : 5;
|
||||
unsigned LUN : 3;
|
||||
|
||||
uint8_t info[12];
|
||||
uint8_t info[12];
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef BASICCDB BASICCDB_t;
|
||||
|
||||
struct CDB6 {
|
||||
uint8_t Opcode;
|
||||
uint8_t Opcode;
|
||||
|
||||
unsigned LBAMSB : 5;
|
||||
unsigned LUN : 3;
|
||||
unsigned LBAMSB : 5;
|
||||
unsigned LUN : 3;
|
||||
|
||||
uint8_t LBAHB;
|
||||
uint8_t LBALB;
|
||||
uint8_t AllocationLength;
|
||||
uint8_t Control;
|
||||
uint8_t LBAHB;
|
||||
uint8_t LBALB;
|
||||
uint8_t AllocationLength;
|
||||
uint8_t Control;
|
||||
|
||||
public:
|
||||
|
||||
CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) :
|
||||
Opcode(_Opcode), LBAMSB(BGRAB2(LBA) & 0x1f), LUN(_LUN), LBAHB(BGRAB1(LBA)), LBALB(BGRAB0(LBA)),
|
||||
AllocationLength(_AllocationLength), Control(_Control) {
|
||||
}
|
||||
CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) :
|
||||
Opcode(_Opcode), LBAMSB(BGRAB2(LBA) & 0x1f), LUN(_LUN), LBAHB(BGRAB1(LBA)), LBALB(BGRAB0(LBA)),
|
||||
AllocationLength(_AllocationLength), Control(_Control) {
|
||||
}
|
||||
|
||||
CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) :
|
||||
Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0),
|
||||
AllocationLength(_AllocationLength), Control(_Control) {
|
||||
}
|
||||
CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) :
|
||||
Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0),
|
||||
AllocationLength(_AllocationLength), Control(_Control) {
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef CDB6 CDB6_t;
|
||||
|
||||
struct CDB10 {
|
||||
uint8_t Opcode;
|
||||
uint8_t Opcode;
|
||||
|
||||
unsigned Service_Action : 5;
|
||||
unsigned LUN : 3;
|
||||
unsigned Service_Action : 5;
|
||||
unsigned LUN : 3;
|
||||
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
|
||||
uint8_t Misc2;
|
||||
uint8_t Misc2;
|
||||
|
||||
uint8_t ALC_MB;
|
||||
uint8_t ALC_LB;
|
||||
uint8_t ALC_MB;
|
||||
uint8_t ALC_LB;
|
||||
|
||||
uint8_t Control;
|
||||
uint8_t Control;
|
||||
public:
|
||||
|
||||
CDB10(uint8_t _Opcode, uint8_t _LUN) :
|
||||
Opcode(_Opcode), Service_Action(0), LUN(_LUN),
|
||||
LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0),
|
||||
Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) {
|
||||
}
|
||||
CDB10(uint8_t _Opcode, uint8_t _LUN) :
|
||||
Opcode(_Opcode), Service_Action(0), LUN(_LUN),
|
||||
LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0),
|
||||
Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) {
|
||||
}
|
||||
|
||||
CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) :
|
||||
Opcode(_Opcode), Service_Action(0), LUN(_LUN),
|
||||
LBA_L_M_MB(BGRAB3(_LBA)), LBA_L_M_LB(BGRAB2(_LBA)), LBA_L_L_MB(BGRAB1(_LBA)), LBA_L_L_LB(BGRAB0(_LBA)),
|
||||
Misc2(0), ALC_MB(BGRAB1(xflen)), ALC_LB(BGRAB0(xflen)), Control(0) {
|
||||
}
|
||||
CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) :
|
||||
Opcode(_Opcode), Service_Action(0), LUN(_LUN),
|
||||
LBA_L_M_MB(BGRAB3(_LBA)), LBA_L_M_LB(BGRAB2(_LBA)), LBA_L_L_MB(BGRAB1(_LBA)), LBA_L_L_LB(BGRAB0(_LBA)),
|
||||
Misc2(0), ALC_MB(BGRAB1(xflen)), ALC_LB(BGRAB0(xflen)), Control(0) {
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef CDB10 CDB10_t;
|
||||
|
||||
struct CDB12 {
|
||||
uint8_t Opcode;
|
||||
uint8_t Opcode;
|
||||
|
||||
unsigned Service_Action : 5;
|
||||
unsigned Misc : 3;
|
||||
unsigned Service_Action : 5;
|
||||
unsigned Misc : 3;
|
||||
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
uint8_t Control;
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
uint8_t Control;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef CDB12 CDB12_t;
|
||||
|
||||
struct CDB_LBA32_16 {
|
||||
uint8_t Opcode;
|
||||
uint8_t Opcode;
|
||||
|
||||
unsigned Service_Action : 5;
|
||||
unsigned Misc : 3;
|
||||
unsigned Service_Action : 5;
|
||||
unsigned Misc : 3;
|
||||
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
|
||||
uint8_t A_M_M_MB;
|
||||
uint8_t A_M_M_LB;
|
||||
uint8_t A_M_L_MB;
|
||||
uint8_t A_M_L_LB;
|
||||
uint8_t A_M_M_MB;
|
||||
uint8_t A_M_M_LB;
|
||||
uint8_t A_M_L_MB;
|
||||
uint8_t A_M_L_LB;
|
||||
|
||||
uint8_t ALC_M_MB;
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
uint8_t ALC_M_MB;
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
|
||||
uint8_t Misc2;
|
||||
uint8_t Control;
|
||||
uint8_t Misc2;
|
||||
uint8_t Control;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CDB_LBA64_16 {
|
||||
uint8_t Opcode;
|
||||
uint8_t Misc;
|
||||
uint8_t Opcode;
|
||||
uint8_t Misc;
|
||||
|
||||
uint8_t LBA_M_M_MB;
|
||||
uint8_t LBA_M_M_LB;
|
||||
uint8_t LBA_M_L_MB;
|
||||
uint8_t LBA_M_L_LB;
|
||||
uint8_t LBA_M_M_MB;
|
||||
uint8_t LBA_M_M_LB;
|
||||
uint8_t LBA_M_L_MB;
|
||||
uint8_t LBA_M_L_LB;
|
||||
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
uint8_t LBA_L_M_MB;
|
||||
uint8_t LBA_L_M_LB;
|
||||
uint8_t LBA_L_L_MB;
|
||||
uint8_t LBA_L_L_LB;
|
||||
|
||||
uint8_t ALC_M_MB;
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
uint8_t ALC_M_MB;
|
||||
uint8_t ALC_M_LB;
|
||||
uint8_t ALC_L_MB;
|
||||
uint8_t ALC_L_LB;
|
||||
|
||||
uint8_t Misc2;
|
||||
uint8_t Control;
|
||||
uint8_t Misc2;
|
||||
uint8_t Control;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct InquiryResponse {
|
||||
uint8_t DeviceType : 5;
|
||||
uint8_t PeripheralQualifier : 3;
|
||||
uint8_t DeviceType : 5;
|
||||
uint8_t PeripheralQualifier : 3;
|
||||
|
||||
unsigned Reserved : 7;
|
||||
unsigned Removable : 1;
|
||||
unsigned Reserved : 7;
|
||||
unsigned Removable : 1;
|
||||
|
||||
uint8_t Version;
|
||||
uint8_t Version;
|
||||
|
||||
unsigned ResponseDataFormat : 4;
|
||||
unsigned HISUP : 1;
|
||||
unsigned NormACA : 1;
|
||||
unsigned TrmTsk : 1;
|
||||
unsigned AERC : 1;
|
||||
unsigned ResponseDataFormat : 4;
|
||||
unsigned HISUP : 1;
|
||||
unsigned NormACA : 1;
|
||||
unsigned TrmTsk : 1;
|
||||
unsigned AERC : 1;
|
||||
|
||||
uint8_t AdditionalLength;
|
||||
//uint8_t Reserved3[2];
|
||||
uint8_t AdditionalLength;
|
||||
//uint8_t Reserved3[2];
|
||||
|
||||
unsigned PROTECT : 1;
|
||||
unsigned Res : 2;
|
||||
unsigned ThreePC : 1;
|
||||
unsigned TPGS : 2;
|
||||
unsigned ACC : 1;
|
||||
unsigned SCCS : 1;
|
||||
unsigned PROTECT : 1;
|
||||
unsigned Res : 2;
|
||||
unsigned ThreePC : 1;
|
||||
unsigned TPGS : 2;
|
||||
unsigned ACC : 1;
|
||||
unsigned SCCS : 1;
|
||||
|
||||
unsigned ADDR16 : 1;
|
||||
unsigned R1 : 1;
|
||||
unsigned R2 : 1;
|
||||
unsigned MCHNGR : 1;
|
||||
unsigned MULTIP : 1;
|
||||
unsigned VS : 1;
|
||||
unsigned ENCSERV : 1;
|
||||
unsigned BQUE : 1;
|
||||
unsigned ADDR16 : 1;
|
||||
unsigned R1 : 1;
|
||||
unsigned R2 : 1;
|
||||
unsigned MCHNGR : 1;
|
||||
unsigned MULTIP : 1;
|
||||
unsigned VS : 1;
|
||||
unsigned ENCSERV : 1;
|
||||
unsigned BQUE : 1;
|
||||
|
||||
unsigned SoftReset : 1;
|
||||
unsigned CmdQue : 1;
|
||||
unsigned Reserved4 : 1;
|
||||
unsigned Linked : 1;
|
||||
unsigned Sync : 1;
|
||||
unsigned WideBus16Bit : 1;
|
||||
unsigned WideBus32Bit : 1;
|
||||
unsigned RelAddr : 1;
|
||||
unsigned SoftReset : 1;
|
||||
unsigned CmdQue : 1;
|
||||
unsigned Reserved4 : 1;
|
||||
unsigned Linked : 1;
|
||||
unsigned Sync : 1;
|
||||
unsigned WideBus16Bit : 1;
|
||||
unsigned WideBus32Bit : 1;
|
||||
unsigned RelAddr : 1;
|
||||
|
||||
uint8_t VendorID[8];
|
||||
uint8_t ProductID[16];
|
||||
uint8_t RevisionID[4];
|
||||
uint8_t VendorID[8];
|
||||
uint8_t ProductID[16];
|
||||
uint8_t RevisionID[4];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CommandBlockWrapperBase {
|
||||
uint32_t dCBWSignature;
|
||||
uint32_t dCBWTag;
|
||||
uint32_t dCBWDataTransferLength;
|
||||
uint8_t bmCBWFlags;
|
||||
uint32_t dCBWSignature;
|
||||
uint32_t dCBWTag;
|
||||
uint32_t dCBWDataTransferLength;
|
||||
uint8_t bmCBWFlags;
|
||||
public:
|
||||
|
||||
CommandBlockWrapperBase() {
|
||||
}
|
||||
CommandBlockWrapperBase() {
|
||||
}
|
||||
|
||||
CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) :
|
||||
dCBWSignature(MASS_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) {
|
||||
}
|
||||
CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) :
|
||||
dCBWSignature(MASS_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) {
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CommandBlockWrapper : public CommandBlockWrapperBase {
|
||||
|
||||
struct {
|
||||
uint8_t bmCBWLUN : 4;
|
||||
uint8_t bmReserved1 : 4;
|
||||
};
|
||||
struct {
|
||||
uint8_t bmCBWLUN : 4;
|
||||
uint8_t bmReserved1 : 4;
|
||||
};
|
||||
|
||||
struct {
|
||||
uint8_t bmCBWCBLength : 4;
|
||||
uint8_t bmReserved2 : 4;
|
||||
};
|
||||
struct {
|
||||
uint8_t bmCBWCBLength : 4;
|
||||
uint8_t bmReserved2 : 4;
|
||||
};
|
||||
|
||||
uint8_t CBWCB[16];
|
||||
uint8_t CBWCB[16];
|
||||
|
||||
public:
|
||||
// All zeroed.
|
||||
// All zeroed.
|
||||
|
||||
CommandBlockWrapper() :
|
||||
CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) {
|
||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||
}
|
||||
CommandBlockWrapper() :
|
||||
CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) {
|
||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||
}
|
||||
|
||||
// Generic Wrap, CDB zeroed.
|
||||
// Generic Wrap, CDB zeroed.
|
||||
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) :
|
||||
CommandBlockWrapperBase(tag, xflen, flgs),
|
||||
bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
|
||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||
// Type punning can cause optimization problems and bugs.
|
||||
// Using reinterpret_cast to a dreinterpretifferent object is the proper way to do this.
|
||||
//(((BASICCDB_t *) CBWCB)->LUN) = cmd;
|
||||
BASICCDB_t *x = reinterpret_cast<BASICCDB_t *>(CBWCB);
|
||||
x->LUN = cmd;
|
||||
}
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) :
|
||||
CommandBlockWrapperBase(tag, xflen, flgs),
|
||||
bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
|
||||
for(int i = 0; i < 16; i++) CBWCB[i] = 0;
|
||||
// Type punning can cause optimization problems and bugs.
|
||||
// Using reinterpret_cast to a dreinterpretifferent object is the proper way to do this.
|
||||
//(((BASICCDB_t *) CBWCB)->LUN) = cmd;
|
||||
BASICCDB_t *x = reinterpret_cast<BASICCDB_t *>(CBWCB);
|
||||
x->LUN = cmd;
|
||||
}
|
||||
|
||||
// Wrap for CDB of 6
|
||||
// Wrap for CDB of 6
|
||||
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB6_t *cdb, uint8_t dir) :
|
||||
CommandBlockWrapperBase(tag, xflen, dir),
|
||||
bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) {
|
||||
memcpy(&CBWCB, cdb, 6);
|
||||
}
|
||||
// Wrap for CDB of 10
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB6_t *cdb, uint8_t dir) :
|
||||
CommandBlockWrapperBase(tag, xflen, dir),
|
||||
bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) {
|
||||
memcpy(&CBWCB, cdb, 6);
|
||||
}
|
||||
// Wrap for CDB of 10
|
||||
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB10_t *cdb, uint8_t dir) :
|
||||
CommandBlockWrapperBase(tag, xflen, dir),
|
||||
bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) {
|
||||
memcpy(&CBWCB, cdb, 10);
|
||||
}
|
||||
CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB10_t *cdb, uint8_t dir) :
|
||||
CommandBlockWrapperBase(tag, xflen, dir),
|
||||
bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) {
|
||||
memcpy(&CBWCB, cdb, 10);
|
||||
}
|
||||
} __attribute__((packed));
|
||||
|
||||
struct CommandStatusWrapper {
|
||||
uint32_t dCSWSignature;
|
||||
uint32_t dCSWTag;
|
||||
uint32_t dCSWDataResidue;
|
||||
uint8_t bCSWStatus;
|
||||
uint32_t dCSWSignature;
|
||||
uint32_t dCSWTag;
|
||||
uint32_t dCSWDataResidue;
|
||||
uint8_t bCSWStatus;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct RequestSenseResponce {
|
||||
uint8_t bResponseCode;
|
||||
uint8_t bSegmentNumber;
|
||||
uint8_t bResponseCode;
|
||||
uint8_t bSegmentNumber;
|
||||
|
||||
uint8_t bmSenseKey : 4;
|
||||
uint8_t bmReserved : 1;
|
||||
uint8_t bmILI : 1;
|
||||
uint8_t bmEOM : 1;
|
||||
uint8_t bmFileMark : 1;
|
||||
uint8_t bmSenseKey : 4;
|
||||
uint8_t bmReserved : 1;
|
||||
uint8_t bmILI : 1;
|
||||
uint8_t bmEOM : 1;
|
||||
uint8_t bmFileMark : 1;
|
||||
|
||||
uint8_t Information[4];
|
||||
uint8_t bAdditionalLength;
|
||||
uint8_t CmdSpecificInformation[4];
|
||||
uint8_t bAdditionalSenseCode;
|
||||
uint8_t bAdditionalSenseQualifier;
|
||||
uint8_t bFieldReplaceableUnitCode;
|
||||
uint8_t SenseKeySpecific[3];
|
||||
uint8_t Information[4];
|
||||
uint8_t bAdditionalLength;
|
||||
uint8_t CmdSpecificInformation[4];
|
||||
uint8_t bAdditionalSenseCode;
|
||||
uint8_t bAdditionalSenseQualifier;
|
||||
uint8_t bFieldReplaceableUnitCode;
|
||||
uint8_t SenseKeySpecific[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
class BulkOnly : public USBDeviceConfig, public UsbConfigXtracter {
|
||||
protected:
|
||||
static const uint8_t epDataInIndex; // DataIn endpoint index
|
||||
static const uint8_t epDataOutIndex; // DataOUT endpoint index
|
||||
static const uint8_t epInterruptInIndex; // InterruptIN endpoint index
|
||||
static const uint8_t epDataInIndex; // DataIn endpoint index
|
||||
static const uint8_t epDataOutIndex; // DataOUT endpoint index
|
||||
static const uint8_t epInterruptInIndex; // InterruptIN endpoint index
|
||||
|
||||
USB *pUsb;
|
||||
uint8_t bAddress;
|
||||
uint8_t bConfNum; // configuration number
|
||||
uint8_t bIface; // interface value
|
||||
uint8_t bNumEP; // total number of EP in the configuration
|
||||
uint32_t qNextPollTime; // next poll time
|
||||
bool bPollEnable; // poll enable flag
|
||||
USB *pUsb;
|
||||
uint8_t bAddress;
|
||||
uint8_t bConfNum; // configuration number
|
||||
uint8_t bIface; // interface value
|
||||
uint8_t bNumEP; // total number of EP in the configuration
|
||||
uint32_t qNextPollTime; // next poll time
|
||||
bool bPollEnable; // poll enable flag
|
||||
|
||||
EpInfo epInfo[MASS_MAX_ENDPOINTS];
|
||||
EpInfo epInfo[MASS_MAX_ENDPOINTS];
|
||||
|
||||
uint32_t dCBWTag; // Tag
|
||||
//uint32_t dCBWDataTransferLength; // Data Transfer Length
|
||||
uint8_t bLastUsbError; // Last USB error
|
||||
uint8_t bMaxLUN; // Max LUN
|
||||
uint8_t bTheLUN; // Active LUN
|
||||
uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors
|
||||
uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits
|
||||
bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes.
|
||||
bool WriteOk[MASS_MAX_SUPPORTED_LUN];
|
||||
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
|
||||
uint32_t dCBWTag; // Tag
|
||||
//uint32_t dCBWDataTransferLength; // Data Transfer Length
|
||||
uint8_t bLastUsbError; // Last USB error
|
||||
uint8_t bMaxLUN; // Max LUN
|
||||
uint8_t bTheLUN; // Active LUN
|
||||
uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors
|
||||
uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits
|
||||
bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes.
|
||||
bool WriteOk[MASS_MAX_SUPPORTED_LUN];
|
||||
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
|
||||
|
||||
|
||||
// Additional Initialization Method for Subclasses
|
||||
// Additional Initialization Method for Subclasses
|
||||
|
||||
virtual uint8_t OnInit() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual uint8_t OnInit() {
|
||||
return 0;
|
||||
};
|
||||
public:
|
||||
BulkOnly(USB *p);
|
||||
BulkOnly(USB *p);
|
||||
|
||||
uint8_t GetLastUsbError() {
|
||||
return bLastUsbError;
|
||||
};
|
||||
uint8_t GetLastUsbError() {
|
||||
return bLastUsbError;
|
||||
};
|
||||
|
||||
uint8_t GetbMaxLUN() {
|
||||
return bMaxLUN; // Max LUN
|
||||
}
|
||||
uint8_t GetbMaxLUN() {
|
||||
return bMaxLUN; // Max LUN
|
||||
}
|
||||
|
||||
uint8_t GetbTheLUN() {
|
||||
return bTheLUN; // Active LUN
|
||||
}
|
||||
uint8_t GetbTheLUN() {
|
||||
return bTheLUN; // Active LUN
|
||||
}
|
||||
|
||||
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 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);
|
||||
bool LUNIsGood(uint8_t lun);
|
||||
uint32_t GetCapacity(uint8_t lun);
|
||||
uint16_t GetSectorSize(uint8_t lun);
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
// USBDeviceConfig implementation
|
||||
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();
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
|
||||
// UsbConfigXtracter implementation
|
||||
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
|
||||
// UsbConfigXtracter implementation
|
||||
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) {
|
||||
return (klass == USB_CLASS_MASS_STORAGE);
|
||||
}
|
||||
virtual bool DEVCLASSOK(uint8_t klass) {
|
||||
return (klass == USB_CLASS_MASS_STORAGE);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
private:
|
||||
uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf);
|
||||
uint8_t TestUnitReady(uint8_t lun);
|
||||
uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf);
|
||||
uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf);
|
||||
uint8_t GetMaxLUN(uint8_t *max_lun);
|
||||
uint8_t SetCurLUN(uint8_t lun);
|
||||
void Reset();
|
||||
uint8_t ResetRecovery();
|
||||
uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf);
|
||||
void ClearAllEP();
|
||||
void CheckMedia();
|
||||
bool CheckLUN(uint8_t lun);
|
||||
uint8_t Page3F(uint8_t lun);
|
||||
bool IsValidCBW(uint8_t size, uint8_t *pcbw);
|
||||
bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw);
|
||||
uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf);
|
||||
uint8_t TestUnitReady(uint8_t lun);
|
||||
uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf);
|
||||
uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf);
|
||||
uint8_t GetMaxLUN(uint8_t *max_lun);
|
||||
uint8_t SetCurLUN(uint8_t lun);
|
||||
void Reset();
|
||||
uint8_t ResetRecovery();
|
||||
uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf);
|
||||
void ClearAllEP();
|
||||
void CheckMedia();
|
||||
bool CheckLUN(uint8_t lun);
|
||||
uint8_t Page3F(uint8_t lun);
|
||||
bool IsValidCBW(uint8_t size, uint8_t *pcbw);
|
||||
bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw);
|
||||
|
||||
bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
|
||||
bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw);
|
||||
|
||||
uint8_t ClearEpHalt(uint8_t index);
|
||||
#if MS_WANT_PARSER
|
||||
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags);
|
||||
#endif
|
||||
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf);
|
||||
uint8_t HandleUsbError(uint8_t error, uint8_t index);
|
||||
uint8_t HandleSCSIError(uint8_t status);
|
||||
uint8_t ClearEpHalt(uint8_t index);
|
||||
#if MS_WANT_PARSER
|
||||
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags);
|
||||
#endif
|
||||
uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf);
|
||||
uint8_t HandleUsbError(uint8_t error, uint8_t index);
|
||||
uint8_t HandleSCSIError(uint8_t status);
|
||||
|
||||
};
|
||||
|
||||
#endif // __MASSTORAGE_H__
|
||||
|
@ -22,8 +22,7 @@ Web : http://www.circuitsathome.com
|
||||
e-mail : support@circuitsathome.com
|
||||
*/
|
||||
|
||||
#ifndef USB_HOST_SHIELD_SETTINGS_H
|
||||
#define USB_HOST_SHIELD_SETTINGS_H
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
@ -232,5 +231,3 @@ e-mail : support@circuitsathome.com
|
||||
#ifdef ARDUINO_ESP8266_WIFIO
|
||||
#error "This board is currently not supported"
|
||||
#endif
|
||||
|
||||
#endif /* SETTINGS_H */
|
||||
|
@ -19,8 +19,7 @@
|
||||
* location: <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _USB_HOST_H_
|
||||
#define _USB_HOST_H_
|
||||
#pragma once
|
||||
|
||||
/* This the following comes from "lib/usbhost.h", but has been rewritten
|
||||
* to use the SPI functions from Marlin's HAL */
|
||||
@ -57,5 +56,3 @@ class MAX3421e {
|
||||
#if defined(__SAM3X8E__) && !defined(ARDUINO_SAM_DUE)
|
||||
#define ARDUINO_SAM_DUE // Spoof the USB library that this is a DUE
|
||||
#endif
|
||||
|
||||
#endif // _USB_HOST_H_
|
||||
|
Reference in New Issue
Block a user