mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Explicit cast millis() and micros() to uint32_t, as it is uint64_t on the Arduino 101
This commit is contained in:
parent
6fb48f48e4
commit
42948831ce
29 changed files with 95 additions and 124 deletions
4
BTD.cpp
4
BTD.cpp
|
@ -384,8 +384,8 @@ uint8_t BTD::Release() {
|
||||||
uint8_t BTD::Poll() {
|
uint8_t BTD::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
if((int32_t)(millis() - qNextPollTime) >= 0L) { // Don't poll if shorter than polling interval
|
if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) { // Don't poll if shorter than polling interval
|
||||||
qNextPollTime = millis() + pollInterval; // Set new poll time
|
qNextPollTime = (uint32_t)millis() + pollInterval; // Set new poll time
|
||||||
HCI_event_task(); // Poll the HCI event pipe
|
HCI_event_task(); // Poll the HCI event pipe
|
||||||
HCI_task(); // HCI state machine
|
HCI_task(); // HCI state machine
|
||||||
ACL_event_task(); // Poll the ACL input pipe too
|
ACL_event_task(); // Poll the ACL input pipe too
|
||||||
|
|
28
PS3BT.cpp
28
PS3BT.cpp
|
@ -339,7 +339,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
||||||
if(PS3Connected || PS3MoveConnected || PS3NavigationConnected) {
|
if(PS3Connected || PS3MoveConnected || PS3NavigationConnected) {
|
||||||
/* Read Report */
|
/* Read Report */
|
||||||
if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
||||||
lastMessageTime = millis(); // Store the last message time
|
lastMessageTime = (uint32_t)millis(); // Store the last message time
|
||||||
|
|
||||||
if(PS3Connected || PS3NavigationConnected)
|
if(PS3Connected || PS3NavigationConnected)
|
||||||
ButtonState = (uint32_t)(l2capinbuf[11] | ((uint16_t)l2capinbuf[12] << 8) | ((uint32_t)l2capinbuf[13] << 16));
|
ButtonState = (uint32_t)(l2capinbuf[11] | ((uint16_t)l2capinbuf[12] << 8) | ((uint32_t)l2capinbuf[13] << 16));
|
||||||
|
@ -420,7 +420,7 @@ void PS3BT::L2CAP_task() {
|
||||||
l2cap_state = TURN_ON_LED;
|
l2cap_state = TURN_ON_LED;
|
||||||
} else
|
} else
|
||||||
l2cap_state = PS3_ENABLE_SIXAXIS;
|
l2cap_state = PS3_ENABLE_SIXAXIS;
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -454,18 +454,18 @@ void PS3BT::L2CAP_task() {
|
||||||
void PS3BT::Run() {
|
void PS3BT::Run() {
|
||||||
switch(l2cap_state) {
|
switch(l2cap_state) {
|
||||||
case PS3_ENABLE_SIXAXIS:
|
case PS3_ENABLE_SIXAXIS:
|
||||||
if((int32_t)(millis() - timer) > 1000) { // loop 1 second before sending the command
|
if((int32_t)((uint32_t)millis() - timer) > 1000) { // loop 1 second before sending the command
|
||||||
memset(l2capinbuf, 0, BULK_MAXPKTSIZE); // Reset l2cap in buffer as it sometimes read it as a button has been pressed
|
memset(l2capinbuf, 0, BULK_MAXPKTSIZE); // Reset l2cap in buffer as it sometimes read it as a button has been pressed
|
||||||
for(uint8_t i = 15; i < 19; i++)
|
for(uint8_t i = 15; i < 19; i++)
|
||||||
l2capinbuf[i] = 0x7F; // Set the analog joystick values to center position
|
l2capinbuf[i] = 0x7F; // Set the analog joystick values to center position
|
||||||
enable_sixaxis();
|
enable_sixaxis();
|
||||||
l2cap_state = TURN_ON_LED;
|
l2cap_state = TURN_ON_LED;
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TURN_ON_LED:
|
case TURN_ON_LED:
|
||||||
if((int32_t)(millis() - timer) > 1000) { // loop 1 second before sending the command
|
if((int32_t)((uint32_t)millis() - timer) > 1000) { // loop 1 second before sending the command
|
||||||
if(remote_name_first == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
if(remote_name_first == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
|
Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
|
||||||
|
@ -477,7 +477,7 @@ void PS3BT::Run() {
|
||||||
#endif
|
#endif
|
||||||
PS3NavigationConnected = true;
|
PS3NavigationConnected = true;
|
||||||
} else if(remote_name_first == 'M') { // First letter in Motion Controller ('M')
|
} else if(remote_name_first == 'M') { // First letter in Motion Controller ('M')
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
|
Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -494,9 +494,9 @@ void PS3BT::Run() {
|
||||||
|
|
||||||
case L2CAP_DONE:
|
case L2CAP_DONE:
|
||||||
if(PS3MoveConnected) { // The Bulb and rumble values, has to be send at approximately every 5th second for it to stay on
|
if(PS3MoveConnected) { // The Bulb and rumble values, has to be send at approximately every 5th second for it to stay on
|
||||||
if((int32_t)(millis() - timer) > 4000) { // Send at least every 4th second
|
if((int32_t)((uint32_t)millis() - timer) > 4000) { // Send at least every 4th second
|
||||||
HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
|
HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -510,10 +510,10 @@ void PS3BT::Run() {
|
||||||
// Playstation Sixaxis Dualshock and Navigation Controller commands
|
// Playstation Sixaxis Dualshock and Navigation Controller commands
|
||||||
|
|
||||||
void PS3BT::HID_Command(uint8_t* data, uint8_t nbytes) {
|
void PS3BT::HID_Command(uint8_t* data, uint8_t nbytes) {
|
||||||
if((int32_t)(millis() - timerHID) <= 150) // Check if is has been more than 150ms since last command
|
if((int32_t)((uint32_t)millis() - timerHID) <= 150) // Check if is has been more than 150ms since last command
|
||||||
delay((uint32_t)(150 - (millis() - timerHID))); // There have to be a delay between commands
|
delay((uint32_t)(150 - ((uint32_t)millis() - timerHID))); // There have to be a delay between commands
|
||||||
pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); // Both the Navigation and Dualshock controller sends data via the control channel
|
pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); // Both the Navigation and Dualshock controller sends data via the control channel
|
||||||
timerHID = millis();
|
timerHID = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3BT::setAllOff() {
|
void PS3BT::setAllOff() {
|
||||||
|
@ -595,10 +595,10 @@ void PS3BT::enable_sixaxis() { // Command used to enable the Dualshock 3 and Nav
|
||||||
// Playstation Move Controller commands
|
// Playstation Move Controller commands
|
||||||
|
|
||||||
void PS3BT::HIDMove_Command(uint8_t* data, uint8_t nbytes) {
|
void PS3BT::HIDMove_Command(uint8_t* data, uint8_t nbytes) {
|
||||||
if((int32_t)(millis() - timerHID) <= 150)// Check if is has been less than 150ms since last command
|
if((int32_t)((uint32_t)millis() - timerHID) <= 150)// Check if is has been less than 150ms since last command
|
||||||
delay((uint32_t)(150 - (millis() - timerHID))); // There have to be a delay between commands
|
delay((uint32_t)(150 - ((uint32_t)millis() - timerHID))); // There have to be a delay between commands
|
||||||
pBtd->L2CAP_Command(hci_handle, data, nbytes, interrupt_scid[0], interrupt_scid[1]); // The Move controller sends it's data via the intterrupt channel
|
pBtd->L2CAP_Command(hci_handle, data, nbytes, interrupt_scid[0], interrupt_scid[1]); // The Move controller sends it's data via the intterrupt channel
|
||||||
timerHID = millis();
|
timerHID = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3BT::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { // Use this to set the Color using RGB values
|
void PS3BT::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { // Use this to set the Color using RGB values
|
||||||
|
|
|
@ -221,7 +221,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
bPollEnable = true;
|
bPollEnable = true;
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
return 0; // Successful configuration
|
return 0; // Successful configuration
|
||||||
|
|
||||||
/* Diagnostic messages */
|
/* Diagnostic messages */
|
||||||
|
@ -276,16 +276,16 @@ uint8_t PS3USB::Poll() {
|
||||||
if(PS3Connected || PS3NavigationConnected) {
|
if(PS3Connected || PS3NavigationConnected) {
|
||||||
uint16_t BUFFER_SIZE = EP_MAXPKTSIZE;
|
uint16_t BUFFER_SIZE = EP_MAXPKTSIZE;
|
||||||
pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1
|
pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1
|
||||||
if((int32_t)(millis() - timer) > 100) { // Loop 100ms before processing data
|
if((int32_t)((uint32_t)millis() - timer) > 100) { // Loop 100ms before processing data
|
||||||
readReport();
|
readReport();
|
||||||
#ifdef PRINTREPORT
|
#ifdef PRINTREPORT
|
||||||
printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB
|
} else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB
|
||||||
if((int32_t)(millis() - timer) > 4000) { // Send at least every 4th second
|
if((int32_t)((uint32_t)millis() - timer) > 4000) { // Send at least every 4th second
|
||||||
Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
|
Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
4
SPP.cpp
4
SPP.cpp
|
@ -370,7 +370,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
#endif
|
#endif
|
||||||
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit
|
sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit
|
||||||
creditSent = true;
|
creditSent = true;
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
waitForLastCommand = true;
|
waitForLastCommand = true;
|
||||||
}
|
}
|
||||||
} else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
|
} else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
|
||||||
|
@ -421,7 +421,7 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPP::Run() {
|
void SPP::Run() {
|
||||||
if(waitForLastCommand && (int32_t)(millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
|
if(waitForLastCommand && (int32_t)((uint32_t)millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
|
Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
22
Usb.cpp
22
Usb.cpp
|
@ -313,7 +313,7 @@ uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8
|
||||||
if(maxpktsize < 1 || maxpktsize > 64)
|
if(maxpktsize < 1 || maxpktsize > 64)
|
||||||
return USB_ERROR_INVALID_MAX_PKT_SIZE;
|
return USB_ERROR_INVALID_MAX_PKT_SIZE;
|
||||||
|
|
||||||
uint32_t timeout = millis() + USB_XFER_TIMEOUT;
|
uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
|
||||||
|
|
||||||
regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
|
regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8
|
||||||
regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
|
regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
|
||||||
rcode = (regRd(rHRSL) & 0x0f);
|
rcode = (regRd(rHRSL) & 0x0f);
|
||||||
|
|
||||||
while(rcode && ((int32_t)(millis() - timeout) < 0L)) {
|
while(rcode && ((int32_t)((uint32_t)millis() - timeout) < 0L)) {
|
||||||
switch(rcode) {
|
switch(rcode) {
|
||||||
case hrNAK:
|
case hrNAK:
|
||||||
nak_count++;
|
nak_count++;
|
||||||
|
@ -375,17 +375,17 @@ breakout:
|
||||||
|
|
||||||
/* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
|
/* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
|
||||||
uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
|
uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
|
||||||
uint32_t timeout = millis() + USB_XFER_TIMEOUT;
|
uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
|
||||||
uint8_t tmpdata;
|
uint8_t tmpdata;
|
||||||
uint8_t rcode = hrSUCCESS;
|
uint8_t rcode = hrSUCCESS;
|
||||||
uint8_t retry_count = 0;
|
uint8_t retry_count = 0;
|
||||||
uint16_t nak_count = 0;
|
uint16_t nak_count = 0;
|
||||||
|
|
||||||
while((int32_t)(millis() - timeout) < 0L) {
|
while((int32_t)((uint32_t)millis() - timeout) < 0L) {
|
||||||
regWr(rHXFR, (token | ep)); //launch the transfer
|
regWr(rHXFR, (token | ep)); //launch the transfer
|
||||||
rcode = USB_ERROR_TRANSFER_TIMEOUT;
|
rcode = USB_ERROR_TRANSFER_TIMEOUT;
|
||||||
|
|
||||||
while((int32_t)(millis() - timeout) < 0L) //wait for transfer completion
|
while((int32_t)((uint32_t)millis() - timeout) < 0L) //wait for transfer completion
|
||||||
{
|
{
|
||||||
tmpdata = regRd(rHIRQ);
|
tmpdata = regRd(rHIRQ);
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ void USB::Task(void) //USB state machine
|
||||||
//intentional fallthrough
|
//intentional fallthrough
|
||||||
case FSHOST: //attached
|
case FSHOST: //attached
|
||||||
if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
|
if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
|
||||||
delay = millis() + USB_SETTLE_DELAY;
|
delay = (uint32_t)millis() + USB_SETTLE_DELAY;
|
||||||
usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
|
usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -476,7 +476,7 @@ void USB::Task(void) //USB state machine
|
||||||
case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
|
case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
|
||||||
break;
|
break;
|
||||||
case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
|
case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
|
||||||
if((int32_t)(millis() - delay) >= 0L)
|
if((int32_t)((uint32_t)millis() - delay) >= 0L)
|
||||||
usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
|
usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
|
||||||
else break; // don't fall through
|
else break; // don't fall through
|
||||||
case USB_ATTACHED_SUBSTATE_RESET_DEVICE:
|
case USB_ATTACHED_SUBSTATE_RESET_DEVICE:
|
||||||
|
@ -488,22 +488,22 @@ void USB::Task(void) //USB state machine
|
||||||
tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
|
tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
|
||||||
regWr(rMODE, tmpdata);
|
regWr(rMODE, tmpdata);
|
||||||
usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
|
usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
|
||||||
//delay = millis() + 20; //20ms wait after reset per USB spec
|
//delay = (uint32_t)millis() + 20; //20ms wait after reset per USB spec
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
|
case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
|
||||||
if(regRd(rHIRQ) & bmFRAMEIRQ) {
|
if(regRd(rHIRQ) & bmFRAMEIRQ) {
|
||||||
//when first SOF received _and_ 20ms has passed we can continue
|
//when first SOF received _and_ 20ms has passed we can continue
|
||||||
/*
|
/*
|
||||||
if (delay < millis()) //20ms passed
|
if (delay < (uint32_t)millis()) //20ms passed
|
||||||
usb_task_state = USB_STATE_CONFIGURING;
|
usb_task_state = USB_STATE_CONFIGURING;
|
||||||
*/
|
*/
|
||||||
usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
|
usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
|
||||||
delay = millis() + 20;
|
delay = (uint32_t)millis() + 20;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case USB_ATTACHED_SUBSTATE_WAIT_RESET:
|
case USB_ATTACHED_SUBSTATE_WAIT_RESET:
|
||||||
if((int32_t)(millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING;
|
if((int32_t)((uint32_t)millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING;
|
||||||
else break; // don't fall through
|
else break; // don't fall through
|
||||||
case USB_STATE_CONFIGURING:
|
case USB_STATE_CONFIGURING:
|
||||||
|
|
||||||
|
|
26
Wii.cpp
26
Wii.cpp
|
@ -121,9 +121,9 @@ void WII::disconnect() { // Use this void to disconnect any of the controllers
|
||||||
#endif
|
#endif
|
||||||
initExtension1(); // This will disable the Motion Plus extension
|
initExtension1(); // This will disable the Motion Plus extension
|
||||||
}
|
}
|
||||||
timer = millis() + 1000; // We have to wait for the message before the rest of the channels can be deactivated
|
timer = (uint32_t)millis() + 1000; // We have to wait for the message before the rest of the channels can be deactivated
|
||||||
} else
|
} else
|
||||||
timer = millis(); // Don't wait
|
timer = (uint32_t)millis(); // Don't wait
|
||||||
// First the HID interrupt channel has to be disconnected, then the HID control channel and finally the HCI connection
|
// First the HID interrupt channel has to be disconnected, then the HID control channel and finally the HCI connection
|
||||||
pBtd->l2cap_disconnection_request(hci_handle, ++identifier, interrupt_scid, interrupt_dcid);
|
pBtd->l2cap_disconnection_request(hci_handle, ++identifier, interrupt_scid, interrupt_dcid);
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -522,13 +522,13 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
if(!(l2capinbuf[19] & 0x02)) // Check if fast mode is used
|
if(!(l2capinbuf[19] & 0x02)) // Check if fast mode is used
|
||||||
rollGyroSpeed *= 4.545;
|
rollGyroSpeed *= 4.545;
|
||||||
|
|
||||||
compPitch = (0.93f * (compPitch + (pitchGyroSpeed * (float)(micros() - timer) / 1000000.0f)))+(0.07f * getWiimotePitch()); // Use a complimentary filter to calculate the angle
|
compPitch = (0.93f * (compPitch + (pitchGyroSpeed * (float)((uint32_t)micros() - timer) / 1000000.0f)))+(0.07f * getWiimotePitch()); // Use a complimentary filter to calculate the angle
|
||||||
compRoll = (0.93f * (compRoll + (rollGyroSpeed * (float)(micros() - timer) / 1000000.0f)))+(0.07f * getWiimoteRoll());
|
compRoll = (0.93f * (compRoll + (rollGyroSpeed * (float)((uint32_t)micros() - timer) / 1000000.0f)))+(0.07f * getWiimoteRoll());
|
||||||
|
|
||||||
gyroYaw += (yawGyroSpeed * ((float)(micros() - timer) / 1000000.0f));
|
gyroYaw += (yawGyroSpeed * ((float)((uint32_t)micros() - timer) / 1000000.0f));
|
||||||
gyroRoll += (rollGyroSpeed * ((float)(micros() - timer) / 1000000.0f));
|
gyroRoll += (rollGyroSpeed * ((float)((uint32_t)micros() - timer) / 1000000.0f));
|
||||||
gyroPitch += (pitchGyroSpeed * ((float)(micros() - timer) / 1000000.0f));
|
gyroPitch += (pitchGyroSpeed * ((float)((uint32_t)micros() - timer) / 1000000.0f));
|
||||||
timer = micros();
|
timer = (uint32_t)micros();
|
||||||
/*
|
/*
|
||||||
// Uncomment these lines to tune the gyro scale variabels
|
// Uncomment these lines to tune the gyro scale variabels
|
||||||
Notify(PSTR("\r\ngyroYaw: "), 0x80);
|
Notify(PSTR("\r\ngyroYaw: "), 0x80);
|
||||||
|
@ -545,7 +545,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
Notify(wiimotePitch, 0x80);
|
Notify(wiimotePitch, 0x80);
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
if((int32_t)(micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
if((int32_t)((uint32_t)micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nThe gyro values has been reset"), 0x80);
|
Notify(PSTR("\r\nThe gyro values has been reset"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -562,7 +562,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
gyroPitch = 0;
|
gyroPitch = 0;
|
||||||
|
|
||||||
motionValuesReset = true;
|
motionValuesReset = true;
|
||||||
timer = micros();
|
timer = (uint32_t)micros();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -698,7 +698,7 @@ void WII::L2CAP_task() {
|
||||||
/* The next states are in run() */
|
/* The next states are in run() */
|
||||||
|
|
||||||
case L2CAP_INTERRUPT_DISCONNECT:
|
case L2CAP_INTERRUPT_DISCONNECT:
|
||||||
if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE) && ((int32_t)(millis() - timer) >= 0L)) {
|
if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE) && ((int32_t)((uint32_t)millis() - timer) >= 0L)) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
@ -723,7 +723,7 @@ void WII::L2CAP_task() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WII::Run() {
|
void WII::Run() {
|
||||||
if(l2cap_state == L2CAP_INTERRUPT_DISCONNECT && ((int32_t)(millis() - timer) >= 0L))
|
if(l2cap_state == L2CAP_INTERRUPT_DISCONNECT && ((int32_t)((uint32_t)millis() - timer) >= 0L))
|
||||||
L2CAP_task(); // Call the rest of the disconnection routine after we have waited long enough
|
L2CAP_task(); // Call the rest of the disconnection routine after we have waited long enough
|
||||||
|
|
||||||
switch(l2cap_state) {
|
switch(l2cap_state) {
|
||||||
|
@ -765,7 +765,7 @@ void WII::Run() {
|
||||||
if(wii_check_flag(WII_FLAG_MOTION_PLUS_CONNECTED)) {
|
if(wii_check_flag(WII_FLAG_MOTION_PLUS_CONNECTED)) {
|
||||||
stateCounter = 0;
|
stateCounter = 0;
|
||||||
l2cap_state = WII_INIT_MOTION_PLUS_STATE;
|
l2cap_state = WII_INIT_MOTION_PLUS_STATE;
|
||||||
timer = micros();
|
timer = (uint32_t)micros();
|
||||||
|
|
||||||
if(unknownExtensionConnected) {
|
if(unknownExtensionConnected) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
|
|
@ -293,8 +293,8 @@ uint8_t XBOXRECV::Release() {
|
||||||
uint8_t XBOXRECV::Poll() {
|
uint8_t XBOXRECV::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
if(!checkStatusTimer || ((int32_t)(millis() - checkStatusTimer) > 3000)) { // Run checkStatus every 3 seconds
|
if(!checkStatusTimer || ((int32_t)((uint32_t)millis() - checkStatusTimer) > 3000)) { // Run checkStatus every 3 seconds
|
||||||
checkStatusTimer = millis();
|
checkStatusTimer = (uint32_t)millis();
|
||||||
checkStatus();
|
checkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,11 +261,11 @@ uint8_t FTDI::Poll() {
|
||||||
//if (!bPollEnable)
|
//if (!bPollEnable)
|
||||||
// return 0;
|
// return 0;
|
||||||
|
|
||||||
//if (qNextPollTime <= millis())
|
//if (qNextPollTime <= (uint32_t)millis())
|
||||||
//{
|
//{
|
||||||
// USB_HOST_SERIAL.println(bAddress, HEX);
|
// USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
|
|
||||||
// qNextPollTime = millis() + 100;
|
// qNextPollTime = (uint32_t)millis() + 100;
|
||||||
//}
|
//}
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,11 +237,11 @@ Fail:
|
||||||
// //if (!bPollEnable)
|
// //if (!bPollEnable)
|
||||||
// // return 0;
|
// // return 0;
|
||||||
//
|
//
|
||||||
// //if (qNextPollTime <= millis())
|
// //if (qNextPollTime <= (uint32_t)millis())
|
||||||
// //{
|
// //{
|
||||||
// // USB_HOST_SERIAL.println(bAddress, HEX);
|
// // USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
//
|
//
|
||||||
// // qNextPollTime = millis() + 100;
|
// // qNextPollTime = (uint32_t)millis() + 100;
|
||||||
// //}
|
// //}
|
||||||
// return rcode;
|
// return rcode;
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -33,8 +33,8 @@ void loop() {
|
||||||
Serial.println(srw1.srws1Data.tilt);
|
Serial.println(srw1.srws1Data.tilt);
|
||||||
} else { // Show strobe light effect
|
} else { // Show strobe light effect
|
||||||
static uint32_t timer;
|
static uint32_t timer;
|
||||||
if ((int32_t)(millis() - timer) > 12) {
|
if ((int32_t)((uint32_t)millis() - timer) > 12) {
|
||||||
timer = millis(); // Reset timer
|
timer = (uint32_t)millis(); // Reset timer
|
||||||
|
|
||||||
static uint16_t leds = 0;
|
static uint16_t leds = 0;
|
||||||
//PrintHex<uint16_t > (leds, 0x80); Serial.println();
|
//PrintHex<uint16_t > (leds, 0x80); Serial.println();
|
||||||
|
|
|
@ -100,8 +100,6 @@ USB Usb;
|
||||||
//USBHub Hub(&Usb);
|
//USBHub Hub(&Usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
|
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
|
||||||
|
|
||||||
uint32_t next_time;
|
|
||||||
|
|
||||||
KbdRptParser Prs;
|
KbdRptParser Prs;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
@ -117,8 +115,6 @@ void setup()
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
next_time = millis() + 5000;
|
|
||||||
|
|
||||||
HidKeyboard.SetReportParser(0, &Prs);
|
HidKeyboard.SetReportParser(0, &Prs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,8 +145,6 @@ HIDBoot < USB_HID_PROTOCOL_KEYBOARD | USB_HID_PROTOCOL_MOUSE > HidComposite(&Usb
|
||||||
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
|
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
||||||
|
|
||||||
//uint32_t next_time;
|
|
||||||
|
|
||||||
KbdRptParser KbdPrs;
|
KbdRptParser KbdPrs;
|
||||||
MouseRptParser MousePrs;
|
MouseRptParser MousePrs;
|
||||||
|
|
||||||
|
@ -163,8 +161,6 @@ void setup()
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
//next_time = millis() + 5000;
|
|
||||||
|
|
||||||
HidComposite.SetReportParser(0, &KbdPrs);
|
HidComposite.SetReportParser(0, &KbdPrs);
|
||||||
HidComposite.SetReportParser(1, &MousePrs);
|
HidComposite.SetReportParser(1, &MousePrs);
|
||||||
HidKeyboard.SetReportParser(0, &KbdPrs);
|
HidKeyboard.SetReportParser(0, &KbdPrs);
|
||||||
|
|
|
@ -54,8 +54,6 @@ USB Usb;
|
||||||
USBHub Hub(&Usb);
|
USBHub Hub(&Usb);
|
||||||
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
||||||
|
|
||||||
uint32_t next_time;
|
|
||||||
|
|
||||||
MouseRptParser Prs;
|
MouseRptParser Prs;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
@ -71,8 +69,6 @@ void setup()
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
next_time = millis() + 5000;
|
|
||||||
|
|
||||||
HidMouse.SetReportParser(0, &Prs);
|
HidMouse.SetReportParser(0, &Prs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,16 +43,11 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//unsigned long t1;
|
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
//t1 = micros();
|
|
||||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
//delay(1ms)
|
|
||||||
//doDelay(t1, micros(), 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
|
@ -69,11 +64,7 @@ void MIDI_poll()
|
||||||
pid = Midi.pid;
|
pid = Midi.pid;
|
||||||
}
|
}
|
||||||
if (Midi.RecvData( &rcvd, bufMidi) == 0 ) {
|
if (Midi.RecvData( &rcvd, bufMidi) == 0 ) {
|
||||||
#ifdef __ARDUINO_ARC__
|
sprintf(buf, "%08lX: ", (uint32_t)millis());
|
||||||
sprintf(buf, "%016llX: ", millis()); // millis() is 64-bits on the Arduino/Genuino 101
|
|
||||||
#else
|
|
||||||
sprintf(buf, "%08lX: ", millis());
|
|
||||||
#endif
|
|
||||||
Serial.print(buf);
|
Serial.print(buf);
|
||||||
Serial.print(rcvd);
|
Serial.print(rcvd);
|
||||||
Serial.print(':');
|
Serial.print(':');
|
||||||
|
|
|
@ -49,16 +49,13 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long t1;
|
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
uint32_t t1 = (uint32_t)micros();
|
||||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
//delay(1ms)
|
doDelay(t1, (uint32_t)micros(), 1000);
|
||||||
doDelay(t1, micros(), 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
|
|
|
@ -51,16 +51,13 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long t1;
|
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
uint32_t t1 = (uint32_t)micros();
|
||||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
}
|
}
|
||||||
//delay(1ms)
|
doDelay(t1, (uint32_t)micros(), 1000);
|
||||||
doDelay(t1, micros(), 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
|
|
|
@ -70,11 +70,10 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long t1;
|
|
||||||
uint8_t msg[4];
|
uint8_t msg[4];
|
||||||
|
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
t1 = micros();
|
uint32_t t1 = (uint32_t)micros();
|
||||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||||
{
|
{
|
||||||
MIDI_poll();
|
MIDI_poll();
|
||||||
|
@ -94,8 +93,7 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//delay(1ms)
|
doDelay(t1, (uint32_t)micros(), 1000);
|
||||||
doDelay(t1, micros(), 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll USB MIDI Controler and send to serial MIDI
|
// Poll USB MIDI Controler and send to serial MIDI
|
||||||
|
|
|
@ -68,8 +68,8 @@ void loop() {
|
||||||
digitalWrite(LED, msg[0] ? HIGH : LOW);
|
digitalWrite(LED, msg[0] ? HIGH : LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int32_t)(millis() - timer) >= 1000) { // Send data every 1s
|
if ((int32_t)((uint32_t)millis() - timer) >= 1000) { // Send data every 1s
|
||||||
timer = millis();
|
timer = (uint32_t)millis();
|
||||||
rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer);
|
rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer);
|
||||||
if (rcode && rcode != hrNAK) {
|
if (rcode && rcode != hrNAK) {
|
||||||
Serial.print(F("\r\nData send: "));
|
Serial.print(F("\r\nData send: "));
|
||||||
|
|
|
@ -41,7 +41,7 @@ void loop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ultoa( millis() / 1000, (char *)buf, 10 );
|
ultoa((uint32_t)millis() / 1000, (char *)buf, 10 );
|
||||||
|
|
||||||
rcode = adk.SndData( strlen((char *)buf), buf );
|
rcode = adk.SndData( strlen((char *)buf), buf );
|
||||||
if (rcode && rcode != hrNAK) {
|
if (rcode && rcode != hrNAK) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ void setup()
|
||||||
|
|
||||||
delay( 200 );
|
delay( 200 );
|
||||||
|
|
||||||
next_time = millis() + 10000;
|
next_time = (uint32_t)millis() + 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintDescriptors(uint8_t addr)
|
void PrintDescriptors(uint8_t addr)
|
||||||
|
@ -96,7 +96,7 @@ void loop()
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
|
|
||||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {
|
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {
|
||||||
if ((int32_t)(millis() - next_time) >= 0L) {
|
if ((int32_t)((uint32_t)millis() - next_time) >= 0L) {
|
||||||
Usb.ForEachUsbDevice(&PrintAllDescriptors);
|
Usb.ForEachUsbDevice(&PrintAllDescriptors);
|
||||||
Usb.ForEachUsbDevice(&PrintAllAddresses);
|
Usb.ForEachUsbDevice(&PrintAllAddresses);
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,5 @@ void loop() {
|
||||||
// Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
|
// Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
|
||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
// Print the number of seconds since reset:
|
// Print the number of seconds since reset:
|
||||||
lcd.print(millis() / 1000);
|
lcd.print((uint32_t)millis() / 1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void loop() {
|
||||||
|
|
||||||
if(Pl.isReady()) {
|
if(Pl.isReady()) {
|
||||||
/* reading the GPS */
|
/* reading the GPS */
|
||||||
if((int32_t)(millis() - read_delay) >= 0L) {
|
if((int32_t)((uint32_t)millis() - read_delay) >= 0L) {
|
||||||
read_delay += READ_DELAY;
|
read_delay += READ_DELAY;
|
||||||
rcode = Pl.RcvData(&rcvd, buf);
|
rcode = Pl.RcvData(&rcvd, buf);
|
||||||
if(rcode && rcode != hrNAK)
|
if(rcode && rcode != hrNAK)
|
||||||
|
|
|
@ -94,10 +94,10 @@ void loop()
|
||||||
if( Pl.isReady()) {
|
if( Pl.isReady()) {
|
||||||
|
|
||||||
bool newdata = false;
|
bool newdata = false;
|
||||||
uint32_t start = millis();
|
uint32_t start = (uint32_t)millis();
|
||||||
|
|
||||||
// Every 5 seconds we print an update
|
// Every 5 seconds we print an update
|
||||||
while ((int32_t)(millis() - start) < 5000) {
|
while ((int32_t)((uint32_t)millis() - start) < 5000) {
|
||||||
if( feedgps()) {
|
if( feedgps()) {
|
||||||
newdata = true;
|
newdata = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ void setup() {
|
||||||
analogWrite(LED_BUILTIN, 0);
|
analogWrite(LED_BUILTIN, 0);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
LEDnext_time = millis() + 1;
|
LEDnext_time = (uint32_t)millis() + 1;
|
||||||
#if EXT_RAM
|
#if EXT_RAM
|
||||||
printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks());
|
printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks());
|
||||||
#endif
|
#endif
|
||||||
|
@ -321,10 +321,10 @@ void setup() {
|
||||||
TIMSK3 |= (1 << OCIE1A);
|
TIMSK3 |= (1 << OCIE1A);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
HEAPnext_time = millis() + 10000;
|
HEAPnext_time = (uint32_t)millis() + 10000;
|
||||||
#endif
|
#endif
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
HEAPnext_time = millis() + 10000;
|
HEAPnext_time = (uint32_t)millis() + 10000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,8 +371,8 @@ void serialEvent() {
|
||||||
// ALL teensy versions LACK PWM ON LED
|
// ALL teensy versions LACK PWM ON LED
|
||||||
|
|
||||||
ISR(TIMER3_COMPA_vect) {
|
ISR(TIMER3_COMPA_vect) {
|
||||||
if((int32_t)(millis() - LEDnext_time) >= 0L) {
|
if((int32_t)((uint32_t)millis() - LEDnext_time) >= 0L) {
|
||||||
LEDnext_time = millis() + 30;
|
LEDnext_time = (uint32_t)millis() + 30;
|
||||||
|
|
||||||
// set the brightness of LED
|
// set the brightness of LED
|
||||||
analogWrite(LED_BUILTIN, brightness);
|
analogWrite(LED_BUILTIN, brightness);
|
||||||
|
@ -407,11 +407,11 @@ void loop() {
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
// Print a heap status report about every 10 seconds.
|
// Print a heap status report about every 10 seconds.
|
||||||
if((int32_t)(millis() - HEAPnext_time) >= 0L) {
|
if((int32_t)((uint32_t)millis() - HEAPnext_time) >= 0L) {
|
||||||
if(UsbDEBUGlvl > 0x50) {
|
if(UsbDEBUGlvl > 0x50) {
|
||||||
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
|
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
|
||||||
}
|
}
|
||||||
HEAPnext_time = millis() + 10000;
|
HEAPnext_time = (uint32_t)millis() + 10000;
|
||||||
}
|
}
|
||||||
TCCR3B = 0;
|
TCCR3B = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -421,7 +421,7 @@ void loop() {
|
||||||
#endif
|
#endif
|
||||||
// Horrid! This sort of thing really belongs in an ISR, not here!
|
// Horrid! This sort of thing really belongs in an ISR, not here!
|
||||||
// We also will be needing to test each hub port, we don't do this yet!
|
// We also will be needing to test each hub port, we don't do this yet!
|
||||||
if(!change && !usbon && (int32_t)(millis() - usbon_time) >= 0L) {
|
if(!change && !usbon && (int32_t)((uint32_t)millis() - usbon_time) >= 0L) {
|
||||||
change = true;
|
change = true;
|
||||||
usbon = true;
|
usbon = true;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ void loop() {
|
||||||
printf_P(PSTR("VBUS on\r\n"));
|
printf_P(PSTR("VBUS on\r\n"));
|
||||||
} else {
|
} else {
|
||||||
Usb.vbusPower(vbus_off);
|
Usb.vbusPower(vbus_off);
|
||||||
usbon_time = millis() + 2000;
|
usbon_time = (uint32_t)millis() + 2000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
|
@ -700,27 +700,27 @@ out:
|
||||||
if(rc) goto failed;
|
if(rc) goto failed;
|
||||||
for(bw = 0; bw < mbxs; bw++) My_Buff_x[bw] = bw & 0xff;
|
for(bw = 0; bw < mbxs; bw++) My_Buff_x[bw] = bw & 0xff;
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
start = millis();
|
start = (uint32_t)millis();
|
||||||
while(start == millis());
|
while(start == (uint32_t)millis());
|
||||||
for(ii = 10485760LU / mbxs; ii > 0LU; ii--) {
|
for(ii = 10485760LU / mbxs; ii > 0LU; ii--) {
|
||||||
rc = f_write(&My_File_Object_x, My_Buff_x, mbxs, &bw);
|
rc = f_write(&My_File_Object_x, My_Buff_x, mbxs, &bw);
|
||||||
if(rc || !bw) goto failed;
|
if(rc || !bw) goto failed;
|
||||||
}
|
}
|
||||||
rc = f_close(&My_File_Object_x);
|
rc = f_close(&My_File_Object_x);
|
||||||
if(rc) goto failed;
|
if(rc) goto failed;
|
||||||
end = millis();
|
end = (uint32_t)millis();
|
||||||
wt = (end - start) - 1;
|
wt = (end - start) - 1;
|
||||||
printf_P(PSTR("Time to write 10485760 bytes: %lu ms (%lu sec) \r\n"), wt, (500 + wt) / 1000UL);
|
printf_P(PSTR("Time to write 10485760 bytes: %lu ms (%lu sec) \r\n"), wt, (500 + wt) / 1000UL);
|
||||||
rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_READ);
|
rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_READ);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
start = millis();
|
start = (uint32_t)millis();
|
||||||
while(start == millis());
|
while(start == (uint32_t)millis());
|
||||||
if(rc) goto failed;
|
if(rc) goto failed;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &bw); /* Read a chunk of file */
|
rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &bw); /* Read a chunk of file */
|
||||||
if(rc || !bw) break; /* Error or end of file */
|
if(rc || !bw) break; /* Error or end of file */
|
||||||
}
|
}
|
||||||
end = millis();
|
end = (uint32_t)millis();
|
||||||
if(rc) goto failed;
|
if(rc) goto failed;
|
||||||
rc = f_close(&My_File_Object_x);
|
rc = f_close(&My_File_Object_x);
|
||||||
if(rc) goto failed;
|
if(rc) goto failed;
|
||||||
|
|
|
@ -578,7 +578,7 @@ template <const uint8_t BOOT_PROTOCOL>
|
||||||
uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
|
uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
|
||||||
uint8_t rcode = 0;
|
uint8_t rcode = 0;
|
||||||
|
|
||||||
if(bPollEnable && ((int32_t)(millis() - qNextPollTime) >= 0L)) {
|
if(bPollEnable && ((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L)) {
|
||||||
|
|
||||||
// To-do: optimize manually, using the for loop only if needed.
|
// To-do: optimize manually, using the for loop only if needed.
|
||||||
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
|
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
|
||||||
|
@ -619,7 +619,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Poll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
qNextPollTime = millis() + bInterval;
|
qNextPollTime = (uint32_t)millis() + bInterval;
|
||||||
}
|
}
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,8 +360,8 @@ uint8_t HIDComposite::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((int32_t)(millis() - qNextPollTime) >= 0L) {
|
if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) {
|
||||||
qNextPollTime = millis() + pollInterval;
|
qNextPollTime = (uint32_t)millis() + pollInterval;
|
||||||
|
|
||||||
uint8_t buf[constBuffLen];
|
uint8_t buf[constBuffLen];
|
||||||
|
|
||||||
|
|
|
@ -372,8 +372,8 @@ uint8_t HIDUniversal::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((int32_t)(millis() - qNextPollTime) >= 0L) {
|
if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) {
|
||||||
qNextPollTime = millis() + pollInterval;
|
qNextPollTime = (uint32_t)millis() + pollInterval;
|
||||||
|
|
||||||
uint8_t buf[constBuffLen];
|
uint8_t buf[constBuffLen];
|
||||||
|
|
||||||
|
|
|
@ -659,7 +659,7 @@ void BulkOnly::CheckMedia() {
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
#endif
|
#endif
|
||||||
qNextPollTime = millis() + 2000;
|
qNextPollTime = (uint32_t)millis() + 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -673,7 +673,7 @@ uint8_t BulkOnly::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((int32_t)(millis() - qNextPollTime) >= 0L) {
|
if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) {
|
||||||
CheckMedia();
|
CheckMedia();
|
||||||
}
|
}
|
||||||
//rcode = 0;
|
//rcode = 0;
|
||||||
|
|
|
@ -232,9 +232,9 @@ uint8_t USBHub::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(((int32_t)(millis() - qNextPollTime) >= 0L)) {
|
if(((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L)) {
|
||||||
rcode = CheckHubStatus();
|
rcode = CheckHubStatus();
|
||||||
qNextPollTime = millis() + 100;
|
qNextPollTime = (uint32_t)millis() + 100;
|
||||||
}
|
}
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue