Bläddra i källkod

Support F_CPU < 20 MHz with USB disabled

teensy4-core
PaulStoffregen 10 år sedan
förälder
incheckning
e42c5cefed
9 ändrade filer med 117 tillägg och 5 borttagningar
  1. +3
    -1
      teensy3/usb_desc.c
  2. +4
    -0
      teensy3/usb_desc.h
  3. +8
    -0
      teensy3/usb_dev.c
  4. +3
    -0
      teensy3/usb_dev.h
  5. +12
    -0
      teensy3/usb_inst.cpp
  6. +3
    -0
      teensy3/usb_mem.c
  7. +4
    -0
      teensy3/usb_seremu.c
  8. +41
    -2
      teensy3/usb_seremu.h
  9. +39
    -2
      teensy3/usb_serial.h

+ 3
- 1
teensy3/usb_desc.c Visa fil

@@ -28,6 +28,8 @@
* SOFTWARE.
*/

#if F_CPU >= 20000000

#include "usb_desc.h"
#include "usb_names.h"
#include "mk20dx128.h"
@@ -890,4 +892,4 @@ const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS] =



#endif // F_CPU >= 20 MHz

+ 4
- 0
teensy3/usb_desc.h Visa fil

@@ -31,6 +31,8 @@
#ifndef _usb_desc_h_
#define _usb_desc_h_

#if F_CPU >= 20000000

// This header is NOT meant to be included when compiling
// user sketches in Arduino. The low-level functions
// provided by usb_dev.c are meant to be called only by
@@ -306,4 +308,6 @@ typedef struct {
extern const usb_descriptor_list_t usb_descriptor_list[];


#endif // F_CPU >= 20 MHz

#endif

+ 8
- 0
teensy3/usb_dev.c Visa fil

@@ -28,6 +28,8 @@
* SOFTWARE.
*/

#if F_CPU >= 20000000

#include "mk20dx128.h"
//#include "HardwareSerial.h"
#include "usb_dev.h"
@@ -969,4 +971,10 @@ void usb_init(void)
}


#else // F_CPU < 20 MHz

void usb_init(void)
{
}

#endif // F_CPU >= 20 MHz

+ 3
- 0
teensy3/usb_dev.h Visa fil

@@ -31,6 +31,8 @@
#ifndef _usb_dev_h_
#define _usb_dev_h_

#if F_CPU >= 20000000

// This header is NOT meant to be included when compiling
// user sketches in Arduino. The low-level functions
// provided by usb_dev.c are meant to be called only by
@@ -101,5 +103,6 @@ extern void usb_flightsim_flush_callback(void);
#endif


#endif // F_CPU >= 20 MHz

#endif

+ 12
- 0
teensy3/usb_inst.cpp Visa fil

@@ -30,6 +30,8 @@

#include "WProgram.h"

#if F_CPU >= 20000000

#ifdef USB_SERIAL
usb_serial_class Serial;
#endif
@@ -65,3 +67,13 @@ FlightSimClass FlightSim;
usb_seremu_class Serial;
#endif


#else // F_CPU < 20 MHz

#if defined(USB_SERIAL) || defined(USB_SERIAL_HID)
usb_serial_class Serial;
#else
usb_seremu_class Serial;
#endif

#endif // F_CPU

+ 3
- 0
teensy3/usb_mem.c Visa fil

@@ -28,6 +28,8 @@
* SOFTWARE.
*/

#if F_CPU >= 20000000

#include "mk20dx128.h"
//#include "HardwareSerial.h"
#include "usb_dev.h"
@@ -104,3 +106,4 @@ void usb_free(usb_packet_t *p)
//serial_print("\n");
}

#endif // F_CPU >= 20 MHz

+ 4
- 0
teensy3/usb_seremu.c Visa fil

@@ -28,6 +28,8 @@
* SOFTWARE.
*/

#if F_CPU >= 20000000

//#include "mk20dx128.h"
#include "usb_dev.h"
#include "usb_seremu.h"
@@ -256,3 +258,5 @@ void usb_seremu_flush_callback(void)
}

#endif // SEREMU_INTERFACE

#endif // F_CPU >= 20 MHz

+ 41
- 2
teensy3/usb_seremu.h Visa fil

@@ -35,6 +35,8 @@

#include <inttypes.h>

#if F_CPU >= 20000000

// C language implementation
#ifdef __cplusplus
extern "C" {
@@ -53,7 +55,6 @@ extern volatile uint8_t usb_configuration;
}
#endif


// C++ interface
#ifdef __cplusplus
#include "Stream.h"
@@ -82,10 +83,48 @@ public:
uint8_t rts(void) { return 1; }
operator bool() { return usb_configuration; }
};

extern usb_seremu_class Serial;
#endif // __cplusplus



#else // F_CPU < 20 MHz

// Allow Arduino programs using Serial to compile, but Serial will do nothing.
#ifdef __cplusplus
#include "Stream.h"
class usb_seremu_class : public Stream
{
public:
void begin(long) { };
void end() { };
virtual int available() { return 0; }
virtual int read() { return -1; }
virtual int peek() { return -1; }
virtual void flush() { }
virtual size_t write(uint8_t c) { return 1; }
virtual size_t write(const uint8_t *buffer, size_t size) { return size; }
size_t write(unsigned long n) { return 1; }
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }
uint8_t stopbits(void) { return 1; }
uint8_t paritytype(void) { return 0; }
uint8_t numbits(void) { return 8; }
uint8_t dtr(void) { return 1; }
uint8_t rts(void) { return 1; }
operator bool() { return true; }
};

extern usb_seremu_class Serial;
#endif // __cplusplus


#endif // F_CPU >= 20 MHz

#endif // USB_HID

#endif // USBseremu_h_

+ 39
- 2
teensy3/usb_serial.h Visa fil

@@ -35,6 +35,8 @@

#include <inttypes.h>

#if F_CPU >= 20000000

// C language implementation
#ifdef __cplusplus
extern "C" {
@@ -58,7 +60,6 @@ extern volatile uint8_t usb_configuration;
#define USB_SERIAL_DTR 0x01
#define USB_SERIAL_RTS 0x02


// C++ interface
#ifdef __cplusplus
#include "Stream.h"
@@ -98,10 +99,46 @@ public:
}

};

extern usb_serial_class Serial;
#endif // __cplusplus


#else // F_CPU < 20 MHz

// Allow Arduino programs using Serial to compile, but Serial will do nothing.
#ifdef __cplusplus
#include "Stream.h"
class usb_serial_class : public Stream
{
public:
void begin(long) { };
void end() { };
virtual int available() { return 0; }
virtual int read() { return -1; }
virtual int peek() { return -1; }
virtual void flush() { }
virtual size_t write(uint8_t c) { return 1; }
virtual size_t write(const uint8_t *buffer, size_t size) { return size; }
size_t write(unsigned long n) { return 1; }
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }
uint8_t stopbits(void) { return 1; }
uint8_t paritytype(void) { return 0; }
uint8_t numbits(void) { return 8; }
uint8_t dtr(void) { return 1; }
uint8_t rts(void) { return 1; }
operator bool() { return true; }
};

extern usb_serial_class Serial;
#endif // __cplusplus

#endif // F_CPU

#endif // USB_SERIAL || USB_SERIAL_HID

#endif // USBserial_h_

Laddar…
Avbryt
Spara