Browse Source

Merge pull request #509 from vjmuzik/T4-No-USB-Support

T4 No USB Support
teensy4-core
Paul Stoffregen 4 years ago
parent
commit
cfb2c3120e
No account linked to committer's email address
3 changed files with 67 additions and 0 deletions
  1. +8
    -0
      teensy4/usb.c
  2. +17
    -0
      teensy4/usb_dev.h
  3. +42
    -0
      teensy4/usb_serial.h

+ 8
- 0
teensy4/usb.c View File



// device mode, page 3155 // device mode, page 3155


#if defined(NUM_ENDPOINTS)

typedef struct endpoint_struct endpoint_t; typedef struct endpoint_struct endpoint_t;


struct endpoint_struct { struct endpoint_struct {
#endif #endif
} }


#else // defined(NUM_ENDPOINTS)

void usb_init(void)
{
}


#endif // defined(NUM_ENDPOINTS)

+ 17
- 0
teensy4/usb_dev.h View File

#pragma once #pragma once
#include "imxrt.h" #include "imxrt.h"


#if !defined(USB_DISABLED)

typedef struct transfer_struct transfer_t; typedef struct transfer_struct transfer_t;
struct transfer_struct { struct transfer_struct {
uint32_t next; uint32_t next;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

#else // !defined(USB_DISABLED)

#ifdef __cplusplus
extern "C" {
#endif

void usb_init(void);

#ifdef __cplusplus
}
#endif


#endif // !defined(USB_DISABLED)

+ 42
- 0
teensy4/usb_serial.h View File



#if (defined(CDC_STATUS_INTERFACE) && defined(CDC_DATA_INTERFACE)) || defined(USB_DISABLED) #if (defined(CDC_STATUS_INTERFACE) && defined(CDC_DATA_INTERFACE)) || defined(USB_DISABLED)


#if !defined(USB_DISABLED)

// C language implementation // C language implementation
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
extern void serialEvent(void); extern void serialEvent(void);
#endif // __cplusplus #endif // __cplusplus


#else // !defined(USB_DISABLED)

// Allow Arduino programs using Serial to compile, but Serial will do nothing.
#ifdef __cplusplus
#include "Stream.h"
class usb_serial_class : public Stream
{
public:
constexpr usb_serial_class() {}
void begin(long) { };
void end() { };
virtual int available() { return 0; }
virtual int read() { return -1; }
virtual int peek() { return -1; }
virtual void flush() { }
virtual void clear() { }
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; }
int availableForWrite() { return 0; }
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;
extern void serialEvent(void);
#endif // __cplusplus

#endif // !defined(USB_DISABLED)

#endif // CDC_STATUS_INTERFACE && CDC_DATA_INTERFACE #endif // CDC_STATUS_INTERFACE && CDC_DATA_INTERFACE





Loading…
Cancel
Save