Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion teensy3/MIDIUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "usb_midi.h"

#ifdef __cplusplus
#if !defined(USB_MIDI) && !defined(USB_MIDI4) && !defined(USB_MIDI16) && !defined(USB_MIDI_SERIAL) && !defined(USB_MIDI4_SERIAL) && !defined(USB_MIDI16_SERIAL) && !defined(USB_MIDI_AUDIO_SERIAL) && !defined(USB_MIDI16_AUDIO_SERIAL) && !defined(USB_EVERYTHING)
#if !defined(MIDI_INTERFACE)
#error "Please select MIDI in Tools > USB Type to use MIDIUSB.h"
#endif

Expand Down
166 changes: 83 additions & 83 deletions teensy3/yield.cpp
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2017 PJRC.COM, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include <Arduino.h>
#include "EventResponder.h"

#ifdef USB_TRIPLE_SERIAL
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1 | YIELD_CHECK_USB_SERIALUSB2; // default to check USB.
extern const uint8_t _serialEventUSB2_default;
extern const uint8_t _serialEventUSB1_default;

#elif defined(USB_DUAL_SERIAL)
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1; // default to check USB.
extern const uint8_t _serialEventUSB1_default;

#else
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL; // default to check USB.
#endif

extern const uint8_t _serialEvent_default;

void yield(void) __attribute__ ((weak));
void yield(void)
{
static uint8_t running=0;
if (!yield_active_check_flags) return; // nothing to do
if (running) return; // TODO: does this need to be atomic?
running = 1;


// USB Serail - Add hack to minimize impact...
if (yield_active_check_flags & YIELD_CHECK_USB_SERIAL) {
if (Serial.available()) serialEvent();
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;
}
// Current workaround until integrate with EventResponder.

#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB1) {
if (SerialUSB1.available()) serialEventUSB1();
if (_serialEventUSB1_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB1;
}
#endif
#ifdef USB_TRIPLE_SERIAL
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB2) {
if (SerialUSB2.available()) serialEventUSB2();
if (_serialEventUSB2_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB2;
}
#endif
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) {
HardwareSerial::processSerialEventsList();
}
running = 0;
if (yield_active_check_flags & YIELD_CHECK_EVENT_RESPONDER) EventResponder::runFromYield();

};
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2017 PJRC.COM, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Arduino.h>
#include "EventResponder.h"
#if defined(CDC3_DATA_INTERFACE) && defined(CDC3_STATUS_INTERFACE)
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1 | YIELD_CHECK_USB_SERIALUSB2; // default to check USB.
extern const uint8_t _serialEventUSB2_default;
extern const uint8_t _serialEventUSB1_default;
#elif defined(CDC2_DATA_INTERFACE) && defined(CDC2_STATUS_INTERFACE)
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1; // default to check USB.
extern const uint8_t _serialEventUSB1_default;
#else
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL; // default to check USB.
#endif
extern const uint8_t _serialEvent_default;
void yield(void) __attribute__ ((weak));
void yield(void)
{
static uint8_t running=0;
if (!yield_active_check_flags) return; // nothing to do
if (running) return; // TODO: does this need to be atomic?
running = 1;
// USB Serail - Add hack to minimize impact...
if (yield_active_check_flags & YIELD_CHECK_USB_SERIAL) {
if (Serial.available()) serialEvent();
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;
}
// Current workaround until integrate with EventResponder.
#if defined(CDC2_DATA_INTERFACE) && defined(CDC2_STATUS_INTERFACE)
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB1) {
if (SerialUSB1.available()) serialEventUSB1();
if (_serialEventUSB1_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB1;
}
#endif
#if defined(CDC3_DATA_INTERFACE) && defined(CDC3_STATUS_INTERFACE)
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB2) {
if (SerialUSB2.available()) serialEventUSB2();
if (_serialEventUSB2_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB2;
}
#endif
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) {
HardwareSerial::processSerialEventsList();
}
running = 0;
if (yield_active_check_flags & YIELD_CHECK_EVENT_RESPONDER) EventResponder::runFromYield();
};
2 changes: 1 addition & 1 deletion teensy4/MIDIUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "usb_midi.h"

#ifdef __cplusplus
#if !defined(USB_MIDI) && !defined(USB_MIDI4) && !defined(USB_MIDI16) && !defined(USB_MIDI_SERIAL) && !defined(USB_MIDI4_SERIAL) && !defined(USB_MIDI16_SERIAL) && !defined(USB_MIDI_AUDIO_SERIAL) && !defined(USB_MIDI16_AUDIO_SERIAL) && !defined(USB_EVERYTHING)
#if !defined(MIDI_INTERFACE)
#error "Please select MIDI in Tools > USB Type to use MIDIUSB.h"
#endif

Expand Down
5 changes: 3 additions & 2 deletions teensy4/MTP_Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// modified for SDFS by WMXZ
// Nov 2020 adapted to SdFat-beta / SD combo

#if defined(USB_MTPDISK) || defined(USB_MTPDISK_SERIAL)
#include "usb_desc.h"
#if defined(MTP_INTERFACE)

#include "core_pins.h"
#include "usb_dev.h"
Expand Down Expand Up @@ -1927,4 +1928,4 @@ void MTPStorage::loop() {
}
}

#endif // USB_MTPDISK or USB_MTPDISK_SERIAL
#endif // MTP_INTERFACE
5 changes: 3 additions & 2 deletions teensy4/MTP_Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

#pragma once

#if defined(USB_MTPDISK) || defined(USB_MTPDISK_SERIAL)
#include "usb_desc.h"
#if defined(MTP_INTERFACE)

#include "core_pins.h"

Expand Down Expand Up @@ -303,4 +304,4 @@ class MTPStorage final {

void mtp_yield(void);

#endif // USB_MTPDISK or USB_MTPDISK_SERIAL
#endif // MTP_INTERFACE
6 changes: 3 additions & 3 deletions teensy4/MTP_Teensy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

// modified for SDFS by WMXZ

#if defined(USB_MTPDISK) || defined(USB_MTPDISK_SERIAL)
#include "usb_desc.h"
#if defined(MTP_INTERFACE)

#define USE_DISK_BUFFER // only currently on T4.x

#include "MTP_Teensy.h"
#include "MTP_Const.h"
#undef USB_DESC_LIST_DEFINE
#include "usb_desc.h"

#if defined(__IMXRT1062__)
// following only while usb_mtp is not included in cores
Expand Down Expand Up @@ -2554,4 +2554,4 @@ void MTP_class::printContainer(const void *container, const char *msg) {



#endif // USB_MTPDISK or USB_MTPDISK_SERIAL
#endif // MTP_INTERFACE
5 changes: 3 additions & 2 deletions teensy4/MTP_Teensy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

#pragma once

#if defined(USB_MTPDISK) || defined(USB_MTPDISK_SERIAL)
#include "usb_desc.h"
#if defined(MTP_INTERFACE)

#include "IntervalTimer.h"
#include "core_pins.h"
Expand Down Expand Up @@ -314,4 +315,4 @@ class MTP_class {

extern MTP_class MTP;

#endif // USB_MTPDISK or USB_MTPDISK_SERIAL
#endif // MTP_INTERFACE
4 changes: 2 additions & 2 deletions teensy4/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ void usb_receive(int endpoint_number, transfer_t *transfer)

uint32_t usb_transfer_status(const transfer_t *transfer)
{
#if defined(USB_MTPDISK) || defined(USB_MTPDISK_SERIAL)
#if defined(MTP_INTERFACE)
uint32_t status, cmd;
//int count=0;
cmd = USB1_USBCMD;
Expand All @@ -1132,7 +1132,7 @@ uint32_t usb_transfer_status(const transfer_t *transfer)
}
#else
return transfer->status;
#endif
#endif // MTP_INTERFACE
}

#else // defined(NUM_ENDPOINTS)
Expand Down
6 changes: 4 additions & 2 deletions teensy4/yield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ void yield(void)
if (Serial.available()) serialEvent();
}

#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
//#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
#if defined(CDC2_DATA_INTERFACE) && defined(CDC2_STATUS_INTERFACE)
if (check_flags & YIELD_CHECK_USB_SERIALUSB1) {
if (SerialUSB1.available()) serialEventUSB1();
}
#endif
#ifdef USB_TRIPLE_SERIAL
//#ifdef USB_TRIPLE_SERIAL
#if defined(CDC3_DATA_INTERFACE) && defined(CDC3_STATUS_INTERFACE)
if (check_flags & YIELD_CHECK_USB_SERIALUSB2) {
if (SerialUSB2.available()) serialEventUSB2();
}
Expand Down