Selaa lähdekoodia

Main loop - call yield - yield can call SerialEvent

Comment out some of the main programs debug print statements plus add yield call to main loop.

yield can now call SerialEvent.

Put hack in that if the user has not overwritten the SerialEvent function, the weak linked one will turn off calling itself...
main
Kurt Eckhardt 5 vuotta sitten
vanhempi
commit
4f24f25a32
4 muutettua tiedostoa jossa 11 lisäystä ja 6 poistoa
  1. +5
    -4
      teensy4/startup.c
  2. +2
    -2
      teensy4/usb_inst.cpp
  3. +1
    -0
      teensy4/usb_serial.h
  4. +3
    -0
      teensy4/yield.cpp

+ 5
- 4
teensy4/startup.c Näytä tiedosto

@@ -112,15 +112,16 @@ void ResetHandler(void)
tempmon_init();

while (millis() < 300) ; // wait at least 300ms before calling user code
printf("before C++ constructors\n");
//printf("before C++ constructors\n");
__libc_init_array();
printf("after C++ constructors\n");
printf("before setup\n");
//printf("after C++ constructors\n");
//printf("before setup\n");
setup();
printf("after setup\n");
//printf("after setup\n");
while (1) {
//printf("loop\n");
loop();
yield();
}
}


+ 2
- 2
teensy4/usb_inst.cpp Näytä tiedosto

@@ -84,6 +84,6 @@ usb_seremu_class Serial;
#endif

#endif // F_CPU
uint8_t usb_enable_serial_event_processing = 1;
void serialEvent() __attribute__((weak));
void serialEvent() {}
void serialEvent() {usb_enable_serial_event_processing = 0;}

+ 1
- 0
teensy4/usb_serial.h Näytä tiedosto

@@ -57,6 +57,7 @@ extern volatile uint32_t systick_millis_count;
extern volatile uint8_t usb_cdc_line_rtsdtr;
extern volatile uint8_t usb_cdc_transmit_flush_timer;
extern volatile uint8_t usb_configuration;
extern uint8_t usb_enable_serial_event_processing;
#ifdef __cplusplus
}
#endif

+ 3
- 0
teensy4/yield.cpp Näytä tiedosto

@@ -39,6 +39,9 @@ void yield(void)
if (running) return; // TODO: does this need to be atomic?
running = 1;

// USB Serail - Add hack to minimize impact...
if (usb_enable_serial_event_processing && Serial.available()) serialEvent();

// Current workaround until integrate with EventResponder.
HardwareSerial::processSerialEvents();


Loading…
Peruuta
Tallenna