소스 검색

Enable No USB for T4

main
Tino Hernandez 4 년 전
부모
커밋
8d430873bb
3개의 변경된 파일67개의 추가작업 그리고 0개의 파일을 삭제
  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 파일 보기

@@ -25,6 +25,8 @@

typedef struct endpoint_struct endpoint_t;

#if defined(NUM_ENDPOINTS)

struct endpoint_struct {
uint32_t config;
uint32_t current;
@@ -1019,4 +1021,10 @@ uint32_t usb_transfer_status(const transfer_t *transfer)
#endif
}

#else // defined(NUM_ENDPOINTS)

void usb_init(void)
{
}

#endif // defined(NUM_ENDPOINTS)

+ 17
- 0
teensy4/usb_dev.h 파일 보기

@@ -1,6 +1,8 @@
#pragma once
#include "imxrt.h"

#if !defined(USB_DISABLED)

typedef struct transfer_struct transfer_t;
struct transfer_struct {
uint32_t next;
@@ -39,3 +41,18 @@ extern void (*usb_timer1_callback)(void);
#ifdef __cplusplus
}
#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 파일 보기

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

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

#if !defined(USB_DISABLED)

// C language implementation
#ifdef __cplusplus
extern "C" {
@@ -123,6 +125,46 @@ extern usb_serial_class Serial;
extern void serialEvent(void);
#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



Loading…
취소
저장