2 #include "../regs/regs.h" 17 if (intsts.getRXFLVL()) {
24 assert(grxstsp.getEPNUM() == 0);
39 if (type == TransactionType::Setup &&
OTG.
DIEPTSIZ0()->getPKTCNT()) {
47 if (type == TransactionType::Setup) {
50 assert(type == TransactionType::Out);
66 if (intsts.getENUMDNE()) {
81 bool Device::isSoftDisconnected()
const {
85 void Device::detach() {
96 case (
int) Request::GetStatus:
97 return getStatus(transferBuffer, transferBufferLength, transferBufferMaxLength);
98 case (
int) Request::SetAddress:
104 setAddress(request->
wValue());
105 *transferBufferLength = 0;
107 case (
int) Request::GetDescriptor:
108 return getDescriptor(request, transferBuffer, transferBufferLength, transferBufferMaxLength);
109 case (
int) Request::SetConfiguration:
110 *transferBufferLength = 0;
111 return setConfiguration(request);
112 case (
int) Request::GetConfiguration:
113 return getConfiguration(transferBuffer, transferBufferLength);
118 bool Device::getStatus(
uint8_t * transferBuffer,
uint16_t * transferBufferLength,
uint16_t transferBufferMaxLength) {
119 *transferBufferLength = min(2, transferBufferMaxLength);
120 for (
int i = 0; i<*transferBufferLength; i++) {
121 transferBuffer[i] = 0;
126 void Device::setAddress(
uint8_t address) {
130 bool Device::getDescriptor(SetupPacket * request,
uint8_t * transferBuffer,
uint16_t * transferBufferLength,
uint16_t transferBufferMaxLength) {
131 Descriptor * wantedDescriptor =
descriptor(request->descriptorType(), request->descriptorIndex());
132 if (wantedDescriptor ==
nullptr) {
135 *transferBufferLength = wantedDescriptor->
copy(transferBuffer, transferBufferMaxLength);
139 bool Device::getConfiguration(
uint8_t * transferBuffer,
uint16_t * transferBufferLength) {
140 *transferBufferLength = 1;
145 bool Device::setConfiguration(SetupPacket * request) {
void readAndDispatchSetupPacket()
virtual void setActiveConfiguration(uint8_t configurationIndex)=0
uint16_t copy(void *target, size_t maxSize) const
virtual uint8_t getActiveConfiguration()=0
constexpr volatile DIEPINT * DIEPINT(int i) const
virtual Descriptor * descriptor(uint8_t type, uint8_t index)=0
void setReceivedPacketSize(uint16_t size)
PKTSTS getPKTSTS() volatile
RequestType requestType() const