瀏覽代碼

Use constexpr constructors for all Serial classes

teensy4-core
PaulStoffregen 7 年之前
父節點
當前提交
768926244c
共有 3 個檔案被更改,包括 10 行新增0 行删除
  1. +6
    -0
      teensy3/HardwareSerial.h
  2. +2
    -0
      teensy3/usb_seremu.h
  3. +2
    -0
      teensy3/usb_serial.h

+ 6
- 0
teensy3/HardwareSerial.h 查看文件

@@ -239,6 +239,7 @@ void serial6_clear(void);
class HardwareSerial : public Stream
{
public:
constexpr HardwareSerial() {}
virtual void begin(uint32_t baud) { serial_begin(BAUD2DIV(baud)); }
virtual void begin(uint32_t baud, uint32_t format) {
serial_begin(BAUD2DIV(baud));
@@ -275,6 +276,7 @@ extern void serialEvent1(void);
class HardwareSerial2 : public HardwareSerial
{
public:
constexpr HardwareSerial2() {}
virtual void begin(uint32_t baud) { serial2_begin(BAUD2DIV2(baud)); }
virtual void begin(uint32_t baud, uint32_t format) {
serial2_begin(BAUD2DIV2(baud));
@@ -311,6 +313,7 @@ extern void serialEvent2(void);
class HardwareSerial3 : public HardwareSerial
{
public:
constexpr HardwareSerial3() {}
virtual void begin(uint32_t baud) { serial3_begin(BAUD2DIV3(baud)); }
virtual void begin(uint32_t baud, uint32_t format) {
serial3_begin(BAUD2DIV3(baud));
@@ -347,6 +350,7 @@ extern void serialEvent3(void);
class HardwareSerial4 : public HardwareSerial
{
public:
constexpr HardwareSerial4() {}
virtual void begin(uint32_t baud) { serial4_begin(BAUD2DIV3(baud)); }
virtual void begin(uint32_t baud, uint32_t format) {
serial4_begin(BAUD2DIV3(baud));
@@ -383,6 +387,7 @@ extern void serialEvent4(void);
class HardwareSerial5 : public HardwareSerial
{
public:
constexpr HardwareSerial5() {}
virtual void begin(uint32_t baud) { serial5_begin(BAUD2DIV3(baud)); }
virtual void begin(uint32_t baud, uint32_t format) {
serial5_begin(BAUD2DIV3(baud));
@@ -419,6 +424,7 @@ extern void serialEvent5(void);
class HardwareSerial6 : public HardwareSerial
{
public:
constexpr HardwareSerial6() {}
#if defined(__MK66FX1M0__) // For LPUART just pass baud straight in.
virtual void begin(uint32_t baud) { serial6_begin(baud); }
virtual void begin(uint32_t baud, uint32_t format) {

+ 2
- 0
teensy3/usb_seremu.h 查看文件

@@ -64,6 +64,7 @@ extern volatile uint8_t usb_configuration;
class usb_seremu_class : public Stream
{
public:
constexpr usb_seremu_class() {}
void begin(long) { /* TODO: call a function that tries to wait for enumeration */ };
void end() { /* TODO: flush output and shut down USB port */ };
virtual int available() { return usb_seremu_available(); }
@@ -101,6 +102,7 @@ extern void serialEvent(void);
class usb_seremu_class : public Stream
{
public:
constexpr usb_seremu_class() {}
void begin(long) { };
void end() { };
virtual int available() { return 0; }

+ 2
- 0
teensy3/usb_serial.h 查看文件

@@ -71,6 +71,7 @@ extern volatile uint8_t usb_configuration;
class usb_serial_class : public Stream
{
public:
constexpr usb_serial_class() {}
void begin(long) {
uint32_t millis_begin = systick_millis_count;
while (!(*this)) {
@@ -128,6 +129,7 @@ extern void serialEvent(void);
class usb_serial_class : public Stream
{
public:
constexpr usb_serial_class() {}
void begin(long) { };
void end() { };
virtual int available() { return 0; }

Loading…
取消
儲存