Browse Source

Merge pull request #5 from PaulStoffregen/master

resync
teensy4-core
duff2013 10 years ago
parent
commit
6534208126
12 changed files with 94 additions and 3 deletions
  1. +9
    -0
      teensy3/HardwareSerial.h
  2. +2
    -0
      teensy3/HardwareSerial1.cpp
  3. +2
    -0
      teensy3/HardwareSerial2.cpp
  4. +2
    -0
      teensy3/HardwareSerial3.cpp
  5. +24
    -1
      teensy3/pins_arduino.h
  6. +10
    -0
      teensy3/serial1.c
  7. +10
    -0
      teensy3/serial2.c
  8. +10
    -0
      teensy3/serial3.c
  9. +3
    -0
      teensy3/usb_inst.cpp
  10. +2
    -0
      teensy3/usb_seremu.h
  11. +2
    -0
      teensy3/usb_serial.h
  12. +18
    -2
      teensy3/yield.cpp

+ 9
- 0
teensy3/HardwareSerial.h View File

void serial_putchar(uint32_t c); void serial_putchar(uint32_t c);
void serial_write(const void *buf, unsigned int count); void serial_write(const void *buf, unsigned int count);
void serial_flush(void); void serial_flush(void);
int serial_room(void);
int serial_available(void); int serial_available(void);
int serial_getchar(void); int serial_getchar(void);
int serial_peek(void); int serial_peek(void);
void serial2_putchar(uint32_t c); void serial2_putchar(uint32_t c);
void serial2_write(const void *buf, unsigned int count); void serial2_write(const void *buf, unsigned int count);
void serial2_flush(void); void serial2_flush(void);
int serial2_room(void);
int serial2_available(void); int serial2_available(void);
int serial2_getchar(void); int serial2_getchar(void);
int serial2_peek(void); int serial2_peek(void);
void serial3_putchar(uint32_t c); void serial3_putchar(uint32_t c);
void serial3_write(const void *buf, unsigned int count); void serial3_write(const void *buf, unsigned int count);
void serial3_flush(void); void serial3_flush(void);
int serial3_room(void);
int serial3_available(void); int serial3_available(void);
int serial3_getchar(void); int serial3_getchar(void);
int serial3_peek(void); int serial3_peek(void);
virtual int read(void) { return serial_getchar(); } virtual int read(void) { return serial_getchar(); }
virtual void flush(void) { serial_flush(); } virtual void flush(void) { serial_flush(); }
virtual void clear(void) { serial_clear(); } virtual void clear(void) { serial_clear(); }
virtual int room(void) { return serial_room(); }
virtual size_t write(uint8_t c) { serial_putchar(c); return 1; } virtual size_t write(uint8_t c) { serial_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write9bit(uint32_t c) { serial_putchar(c); return 1; } virtual size_t write9bit(uint32_t c) { serial_putchar(c); return 1; }
}; };
extern HardwareSerial Serial1; extern HardwareSerial Serial1;
extern void serialEvent1(void);


class HardwareSerial2 : public HardwareSerial class HardwareSerial2 : public HardwareSerial
{ {
virtual int read(void) { return serial2_getchar(); } virtual int read(void) { return serial2_getchar(); }
virtual void flush(void) { serial2_flush(); } virtual void flush(void) { serial2_flush(); }
virtual void clear(void) { serial2_clear(); } virtual void clear(void) { serial2_clear(); }
virtual int room(void) { return serial2_room(); }
virtual size_t write(uint8_t c) { serial2_putchar(c); return 1; } virtual size_t write(uint8_t c) { serial2_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write9bit(uint32_t c) { serial2_putchar(c); return 1; } virtual size_t write9bit(uint32_t c) { serial2_putchar(c); return 1; }
}; };
extern HardwareSerial2 Serial2; extern HardwareSerial2 Serial2;
extern void serialEvent2(void);


class HardwareSerial3 : public HardwareSerial class HardwareSerial3 : public HardwareSerial
{ {
virtual int read(void) { return serial3_getchar(); } virtual int read(void) { return serial3_getchar(); }
virtual void flush(void) { serial3_flush(); } virtual void flush(void) { serial3_flush(); }
virtual void clear(void) { serial3_clear(); } virtual void clear(void) { serial3_clear(); }
virtual int room(void) { return serial3_room(); }
virtual size_t write(uint8_t c) { serial3_putchar(c); return 1; } virtual size_t write(uint8_t c) { serial3_putchar(c); return 1; }
virtual size_t write(unsigned long n) { return write((uint8_t)n); } virtual size_t write(unsigned long n) { return write((uint8_t)n); }
virtual size_t write(long n) { return write((uint8_t)n); } virtual size_t write(long n) { return write((uint8_t)n); }
virtual size_t write9bit(uint32_t c) { serial3_putchar(c); return 1; } virtual size_t write9bit(uint32_t c) { serial3_putchar(c); return 1; }
}; };
extern HardwareSerial3 Serial3; extern HardwareSerial3 Serial3;
extern void serialEvent3(void);


#endif #endif
#endif #endif

+ 2
- 0
teensy3/HardwareSerial1.cpp View File



HardwareSerial Serial1; HardwareSerial Serial1;


void serialEvent1() __attribute__((weak));
void serialEvent1() {}

+ 2
- 0
teensy3/HardwareSerial2.cpp View File



HardwareSerial2 Serial2; HardwareSerial2 Serial2;


void serialEvent2() __attribute__((weak));
void serialEvent2() {}

+ 2
- 0
teensy3/HardwareSerial3.cpp View File



HardwareSerial3 Serial3; HardwareSerial3 Serial3;


void serialEvent3() __attribute__((weak));
void serialEvent3() {}

+ 24
- 1
teensy3/pins_arduino.h View File

return NOT_ON_TIMER; return NOT_ON_TIMER;
} }



// These serial port names are intended to allow libraries and architecture-neutral
// sketches to automatically default to the correct port name for a particular type
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
//
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
//
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
//
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
//
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
//
#define SERIAL_PORT_MONITOR Serial
#define SERIAL_PORT_USBVIRTUAL Serial
#define SERIAL_PORT_HARDWARE Serial1
#define SERIAL_PORT_HARDWARE1 Serial2
#define SERIAL_PORT_HARDWARE2 Serial3
#define SERIAL_PORT_HARDWARE_OPEN Serial1
#define SERIAL_PORT_HARDWARE_OPEN1 Serial2
#define SERIAL_PORT_HARDWARE_OPEN2 Serial3




#endif #endif

+ 10
- 0
teensy3/serial1.c View File

while (transmitting) yield(); // wait while (transmitting) yield(); // wait
} }


int serial_room(void)
{
uint32_t head, tail;

head = tx_buffer_head;
tail = tx_buffer_tail;
if (head >= tail) return TX_BUFFER_SIZE - 1 - head + tail;
return tail - head - 1;
}

int serial_available(void) int serial_available(void)
{ {
uint32_t head, tail; uint32_t head, tail;

+ 10
- 0
teensy3/serial2.c View File

while (transmitting) yield(); // wait while (transmitting) yield(); // wait
} }


int serial2_room(void)
{
uint32_t head, tail;

head = tx_buffer_head;
tail = tx_buffer_tail;
if (head >= tail) return TX_BUFFER_SIZE - 1 - head + tail;
return tail - head - 1;
}

int serial2_available(void) int serial2_available(void)
{ {
uint32_t head, tail; uint32_t head, tail;

+ 10
- 0
teensy3/serial3.c View File

while (transmitting) yield(); // wait while (transmitting) yield(); // wait
} }


int serial3_room(void)
{
uint32_t head, tail;

head = tx_buffer_head;
tail = tx_buffer_tail;
if (head >= tail) return TX_BUFFER_SIZE - 1 - head + tail;
return tail - head - 1;
}

int serial3_available(void) int serial3_available(void)
{ {
uint32_t head, tail; uint32_t head, tail;

+ 3
- 0
teensy3/usb_inst.cpp View File

#endif #endif


#endif // F_CPU #endif // F_CPU

void serialEvent() __attribute__((weak));
void serialEvent() {}

+ 2
- 0
teensy3/usb_seremu.h View File

operator bool() { return usb_configuration; } operator bool() { return usb_configuration; }
}; };
extern usb_seremu_class Serial; extern usb_seremu_class Serial;
extern void serialEvent(void);
#endif // __cplusplus #endif // __cplusplus




}; };


extern usb_seremu_class Serial; extern usb_seremu_class Serial;
extern void serialEvent(void);
#endif // __cplusplus #endif // __cplusplus





+ 2
- 0
teensy3/usb_serial.h View File



}; };
extern usb_serial_class Serial; extern usb_serial_class Serial;
extern void serialEvent(void);
#endif // __cplusplus #endif // __cplusplus




}; };


extern usb_serial_class Serial; extern usb_serial_class Serial;
extern void serialEvent(void);
#endif // __cplusplus #endif // __cplusplus


#endif // F_CPU #endif // F_CPU

teensy3/yield.c → teensy3/yield.cpp View File

/* Teensyduino Core Library /* Teensyduino Core Library
* http://www.pjrc.com/teensy/ * http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Copyright (c) 2014 PJRC.COM, LLC.
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* SOFTWARE. * SOFTWARE.
*/ */


#include "core_pins.h"
#include "HardwareSerial.h"
#include "usb_serial.h"
#include "usb_seremu.h"

void yield(void) __attribute__ ((weak)); void yield(void) __attribute__ ((weak));
void yield(void) {};
void yield(void)
{
static uint8_t running=0;

if (running) return; // TODO: does this need to be atomic?
running = 1;
if (Serial.available()) serialEvent();
if (Serial1.available()) serialEvent1();
if (Serial2.available()) serialEvent2();
if (Serial3.available()) serialEvent3();
running = 0;
};

Loading…
Cancel
Save