PaulStoffregen 10 years ago
parent
commit
d289954223
4 changed files with 36 additions and 0 deletions
  1. +6
    -0
      teensy3/HardwareSerial.h
  2. +10
    -0
      teensy3/serial1.c
  3. +10
    -0
      teensy3/serial2.c
  4. +10
    -0
      teensy3/serial3.c

+ 6
- 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 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 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); }

+ 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 - head + tail;
return tail - head;
}

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 - head + tail;
return tail - head;
}

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 - head + tail;
return tail - head;
}

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

Loading…
Cancel
Save